HTTP/2 Decompress/Compress buffer leak
Motivation: The interface for HTTP/2 onDataRead states that buffers will be released by the codec. The decompressor and compressor methods are not releasing buffers created during the decompression/compression process. Modifications: After onDataRead calls the decompressor and compressor classes will release the data buffer. Result: HTTP/2 compressor/decompressors are consistent with onDataRead interface assumptions.
This commit is contained in:
parent
9173a2fb7c
commit
908b68da03
@ -94,23 +94,30 @@ public class DelegatingDecompressorFrameListener extends Http2FrameListenerDecor
|
||||
decompressor.incrementDecompressedByes(compressedBytes);
|
||||
processedBytes = compressedBytes;
|
||||
} else {
|
||||
decompressor.incrementDecompressedByes(padding);
|
||||
for (;;) {
|
||||
ByteBuf nextBuf = nextReadableBuf(channel);
|
||||
boolean decompressedEndOfStream = nextBuf == null && endOfStream;
|
||||
if (decompressedEndOfStream && channel.finish()) {
|
||||
nextBuf = nextReadableBuf(channel);
|
||||
decompressedEndOfStream = nextBuf == null;
|
||||
}
|
||||
try {
|
||||
decompressor.incrementDecompressedByes(padding);
|
||||
for (;;) {
|
||||
ByteBuf nextBuf = nextReadableBuf(channel);
|
||||
boolean decompressedEndOfStream = nextBuf == null && endOfStream;
|
||||
if (decompressedEndOfStream && channel.finish()) {
|
||||
nextBuf = nextReadableBuf(channel);
|
||||
decompressedEndOfStream = nextBuf == null;
|
||||
}
|
||||
|
||||
decompressor.incrementDecompressedByes(buf.readableBytes());
|
||||
processedBytes += listener.onDataRead(ctx, streamId, buf, padding, decompressedEndOfStream);
|
||||
if (nextBuf == null) {
|
||||
break;
|
||||
}
|
||||
decompressor.incrementDecompressedByes(buf.readableBytes());
|
||||
processedBytes += listener.onDataRead(ctx, streamId, buf, padding, decompressedEndOfStream);
|
||||
if (nextBuf == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
padding = 0; // Padding is only communicated once on the first iteration
|
||||
buf = nextBuf;
|
||||
padding = 0; // Padding is only communicated once on the first iteration
|
||||
buf.release();
|
||||
buf = nextBuf;
|
||||
}
|
||||
} finally {
|
||||
if (buf != null) {
|
||||
buf.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,6 @@ public class DataCompressionHttp2Test {
|
||||
int processedBytes = buf.readableBytes() + padding;
|
||||
|
||||
buf.readBytes(serverOut, buf.readableBytes());
|
||||
buf.release();
|
||||
return processedBytes;
|
||||
}
|
||||
}).when(serverListener).onDataRead(any(ChannelHandlerContext.class), anyInt(),
|
||||
|
Loading…
Reference in New Issue
Block a user