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);
|
decompressor.incrementDecompressedByes(compressedBytes);
|
||||||
processedBytes = compressedBytes;
|
processedBytes = compressedBytes;
|
||||||
} else {
|
} else {
|
||||||
decompressor.incrementDecompressedByes(padding);
|
try {
|
||||||
for (;;) {
|
decompressor.incrementDecompressedByes(padding);
|
||||||
ByteBuf nextBuf = nextReadableBuf(channel);
|
for (;;) {
|
||||||
boolean decompressedEndOfStream = nextBuf == null && endOfStream;
|
ByteBuf nextBuf = nextReadableBuf(channel);
|
||||||
if (decompressedEndOfStream && channel.finish()) {
|
boolean decompressedEndOfStream = nextBuf == null && endOfStream;
|
||||||
nextBuf = nextReadableBuf(channel);
|
if (decompressedEndOfStream && channel.finish()) {
|
||||||
decompressedEndOfStream = nextBuf == null;
|
nextBuf = nextReadableBuf(channel);
|
||||||
}
|
decompressedEndOfStream = nextBuf == null;
|
||||||
|
}
|
||||||
|
|
||||||
decompressor.incrementDecompressedByes(buf.readableBytes());
|
decompressor.incrementDecompressedByes(buf.readableBytes());
|
||||||
processedBytes += listener.onDataRead(ctx, streamId, buf, padding, decompressedEndOfStream);
|
processedBytes += listener.onDataRead(ctx, streamId, buf, padding, decompressedEndOfStream);
|
||||||
if (nextBuf == null) {
|
if (nextBuf == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
padding = 0; // Padding is only communicated once on the first iteration
|
padding = 0; // Padding is only communicated once on the first iteration
|
||||||
buf = nextBuf;
|
buf.release();
|
||||||
|
buf = nextBuf;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (buf != null) {
|
||||||
|
buf.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,6 @@ public class DataCompressionHttp2Test {
|
|||||||
int processedBytes = buf.readableBytes() + padding;
|
int processedBytes = buf.readableBytes() + padding;
|
||||||
|
|
||||||
buf.readBytes(serverOut, buf.readableBytes());
|
buf.readBytes(serverOut, buf.readableBytes());
|
||||||
buf.release();
|
|
||||||
return processedBytes;
|
return processedBytes;
|
||||||
}
|
}
|
||||||
}).when(serverListener).onDataRead(any(ChannelHandlerContext.class), anyInt(),
|
}).when(serverListener).onDataRead(any(ChannelHandlerContext.class), anyInt(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user