HTTP/2 Compressor buffer leak
Motivation: The HTTP/2 compressor does not release the input buffer when compression is done. This results in buffer leaks. Modifications: - Release the buffer in the HTTP/2 compressor - Update tests to reflect the correct state Result: 1 less buffer leak.
This commit is contained in:
parent
908b68da03
commit
dc9ca1a2b8
@ -111,8 +111,8 @@ public class CompressorHttp2ConnectionEncoder extends DefaultHttp2ConnectionEnco
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// call retain here as it will call release after its written to the channel
|
// The channel will release the buffer after being written
|
||||||
channel.writeOutbound(data.retain());
|
channel.writeOutbound(data);
|
||||||
ByteBuf buf = nextReadableBuf(channel);
|
ByteBuf buf = nextReadableBuf(channel);
|
||||||
if (buf == null) {
|
if (buf == null) {
|
||||||
if (endOfStream) {
|
if (endOfStream) {
|
||||||
|
@ -150,7 +150,7 @@ public class DataCompressionHttp2Test {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
||||||
clientEncoder.writeData(ctxClient(), 3, data, 0, true, newPromiseClient());
|
clientEncoder.writeData(ctxClient(), 3, data.retain(), 0, true, newPromiseClient());
|
||||||
ctxClient().flush();
|
ctxClient().flush();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -179,7 +179,7 @@ public class DataCompressionHttp2Test {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
||||||
clientEncoder.writeData(ctxClient(), 3, data, 0, true, newPromiseClient());
|
clientEncoder.writeData(ctxClient(), 3, data.retain(), 0, true, newPromiseClient());
|
||||||
ctxClient().flush();
|
ctxClient().flush();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -210,8 +210,8 @@ public class DataCompressionHttp2Test {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
||||||
clientEncoder.writeData(ctxClient(), 3, data1, 0, false, newPromiseClient());
|
clientEncoder.writeData(ctxClient(), 3, data1.retain(), 0, false, newPromiseClient());
|
||||||
clientEncoder.writeData(ctxClient(), 3, data2, 0, true, newPromiseClient());
|
clientEncoder.writeData(ctxClient(), 3, data2.retain(), 0, true, newPromiseClient());
|
||||||
ctxClient().flush();
|
ctxClient().flush();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -258,7 +258,7 @@ public class DataCompressionHttp2Test {
|
|||||||
public void run() {
|
public void run() {
|
||||||
clientEncoder.writeSettings(ctxClient(), settings, newPromiseClient());
|
clientEncoder.writeSettings(ctxClient(), settings, newPromiseClient());
|
||||||
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
||||||
clientEncoder.writeData(ctxClient(), 3, data, 0, true, newPromiseClient());
|
clientEncoder.writeData(ctxClient(), 3, data.retain(), 0, true, newPromiseClient());
|
||||||
ctxClient().flush();
|
ctxClient().flush();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -302,7 +302,7 @@ public class DataCompressionHttp2Test {
|
|||||||
public void run() {
|
public void run() {
|
||||||
clientEncoder.writeSettings(ctxClient(), settings, newPromiseClient());
|
clientEncoder.writeSettings(ctxClient(), settings, newPromiseClient());
|
||||||
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
clientEncoder.writeHeaders(ctxClient(), 3, headers, 0, false, newPromiseClient());
|
||||||
clientEncoder.writeData(ctxClient(), 3, data, 0, true, newPromiseClient());
|
clientEncoder.writeData(ctxClient(), 3, data.retain(), 0, true, newPromiseClient());
|
||||||
ctxClient().flush();
|
ctxClient().flush();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user