Skip to content

Commit 3d45a1e

Browse files
authored
Merge commit from fork
HTTP2: DelegatingDecompressorFrameListener must release memory in all cases Motivation: We need to ensure we also release the buffer if the flow controller for example throws, missing to do so might result in OOME. Modifications: Move buf.release() to finally block Result: Always release buffer
1 parent 75127ca commit 3d45a1e

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,22 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
387387
return;
388388
}
389389

390-
// Also take padding into account.
391-
incrementDecompressedBytes(padding);
392-
393-
incrementDecompressedBytes(buf.readableBytes());
394-
// Immediately return the bytes back to the flow controller. ConsumedBytesConverter will convert
395-
// from the decompressed amount which the user knows about to the compressed amount which flow
396-
// control knows about.
397-
connection.local().flowController().consumeBytes(stream,
398-
listener.onDataRead(targetCtx, stream.id(), buf, padding, false));
399-
padding = 0; // Padding is only communicated once on the first iteration.
400-
buf.release();
401-
402-
dataDecompressed = true;
390+
try {
391+
// Also take padding into account.
392+
incrementDecompressedBytes(padding);
393+
394+
incrementDecompressedBytes(buf.readableBytes());
395+
// Immediately return the bytes back to the flow controller. ConsumedBytesConverter will convert
396+
// from the decompressed amount which the user knows about to the compressed amount which flow
397+
// control knows about.
398+
connection.local().flowController().consumeBytes(stream,
399+
listener.onDataRead(targetCtx, stream.id(), buf, padding, false));
400+
padding = 0; // Padding is only communicated once on the first iteration.
401+
402+
dataDecompressed = true;
403+
} finally {
404+
buf.release();
405+
}
403406
}
404407

405408
@Override

0 commit comments

Comments
 (0)