GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HTTP2: Don't leak buffer when using compression and the stream is clo… · lltopk/netty@e9cec3f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-http2/src/main/java/io/netty/handler/codec/http2
    • DelegatingDecompressorFrameListener.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import io.netty.handler.codec.compression.ZlibWrapper;
3030
import io.netty.handler.codec.compression.SnappyFrameDecoder;
3131

32+
import java.nio.channels.ClosedChannelException;
33+
3234
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_ENCODING;
3335
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH;
3436
import static io.netty.handler.codec.http.HttpHeaderValues.BR;
@@ -429,6 +431,15 @@ int decompress(ChannelHandlerContext ctx, Http2Stream stream, ByteBuf data, int
429431
this.dataDecompressed = false;
430432
this.targetCtx = ctx;
431433

434+
if (!decompressor.isOpen()) {
435+
// Directly throw an exception in this case which we will handle in the catch block below.
436+
// This is required as otherwise it will impossible for us to know if the used EmbeddedChannel
437+
// did throw because it was closed already or because of other reasons. We need this knowledge
438+
// to know if we need to call data.release() ourselves after it was retained or not. This is needed
439+
// as EmbeddedChannel will not release the buffer if it throws because it was not open.
440+
// This mimics what EmbeddedChannel will throw.
441+
throw new ClosedChannelException();
442+
}
432443
// call retain here as it will call release after its written to the channel
433444
decompressor.writeInbound(data.retain());
434445
if (endOfStream) {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.