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 — Port 5.0: Avoid classloader leak via the QPACK stream inactive exceptions (#18343) by normanmaurer · Pull Request #18357 · netty/netty

Port 5.0: Avoid classloader leak via the QPACK stream inactive exceptions (#18343) #18357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
normanmaurer merged 1 commit into netty:5.0 from normanmaurer:simple-meadow-81792cbc
Nov 12, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Port 5.0: Avoid classloader leak via the QPACK stream inactive exceptions (#18343) #18357

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
954dfb2
Avoid classloader leak via the QPACK stream inactive exceptions (#18343)
cardamon Nov 12, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Avoid classloader leak via the QPACK stream inactive exceptions (#18343)
Motivation:

The QPACK encoder and decoder stream initializers of
`Http3ControlStreamInboundHandler` keep a static
`ClosedChannelException`. `ThrowableUtil.unknownStackTrace(...)`
replaces its visible stack trace, but not its native backtrace, which
references the classes of every frame on the stack of whatever code
triggered the class initialization. When Netty is shared by the web
applications of a servlet container, this pins the class loader of the
first one that used HTTP/3. Same mechanism as #17128.

Modification:

- Use `StacklessClosedChannelException` for both exceptions.
- Move them from the private nested initializers to package-private
fields of `Http3ControlStreamInboundHandler`, so that a test can check
them. They are only observable when a QPACK stream closes before it
becomes active.
- Add a regression test.

Result:

The QPACK stream inactive exceptions no longer keep the class loader of
their first caller alive.

(cherry picked from commit 77e1af2)
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@cardamon @normanmaurer
cardamon authored and normanmaurer committed Nov 12, 2026
commit 954dfb2772230fbdbfbcf7002cd0571f9586ba6f

There are no files selected for viewing

13 changes: 8 additions & 5 deletions 13 codec-http3/src/main/java/io/netty/handler/codec/http3/Http3ControlStreamInboundHandler.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelShutdownDirection;
import io.netty.channel.ChannelShutdownType;
import io.netty.channel.StacklessClosedChannelException;
import io.netty.handler.codec.quic.QuicChannel;
import io.netty.handler.codec.quic.QuicStreamChannel;
import io.netty.handler.codec.quic.QuicStreamType;
Expand All @@ -38,9 +39,15 @@
import static io.netty.handler.codec.http3.Http3ErrorCode.H3_MISSING_SETTINGS;
import static io.netty.handler.codec.http3.Http3ErrorCode.QPACK_ENCODER_STREAM_ERROR;
import static io.netty.handler.codec.http3.QpackUtil.toIntOrThrow;
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;

final class Http3ControlStreamInboundHandler extends Http3FrameTypeInboundValidationHandler<Http3ControlStreamFrame> {
// Stackless, as a populated backtrace would pin the Classloader of whatever thread happened to trigger the
// class initialization (see https://github.com/netty/netty/issues/17128).
static final ClosedChannelException ENCODER_STREAM_INACTIVE =
StacklessClosedChannelException.newInstance(QPackEncoderStreamInitializer.class, "streamClosed()");
static final ClosedChannelException DECODER_STREAM_INACTIVE =
StacklessClosedChannelException.newInstance(QPackDecoderStreamInitializer.class, "streamClosed()");

final boolean server;
private final ChannelHandler controlFrameHandler;
private final QpackEncoder qpackEncoder;
Expand Down Expand Up @@ -278,8 +285,6 @@ public void channelInactive(ChannelHandlerContext ctx) {
}

private static final class QPackEncoderStreamInitializer extends AbstractQPackStreamInitializer {
private static final ClosedChannelException ENCODER_STREAM_INACTIVE =
unknownStackTrace(new ClosedChannelException(), ClosedChannelException.class, "streamClosed()");
private final QpackEncoder encoder;
private final long maxTableCapacity;
private final long blockedStreams;
Expand Down Expand Up @@ -312,8 +317,6 @@ protected void streamClosed(ChannelHandlerContext ctx) {
}

private static final class QPackDecoderStreamInitializer extends AbstractQPackStreamInitializer {
private static final ClosedChannelException DECODER_STREAM_INACTIVE =
unknownStackTrace(new ClosedChannelException(), ClosedChannelException.class, "streamClosed()");
private QPackDecoderStreamInitializer(QpackAttributes attributes) {
super(Http3CodecUtils.HTTP3_QPACK_DECODER_STREAM_TYPE, attributes);
}
Expand Down
22 changes: 22 additions & 0 deletions 22 ...ttp3/src/test/java/io/netty/handler/codec/http3/Http3ControlStreamInboundHandlerTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.quic.QuicStreamType;
import io.netty.util.ReferenceCountUtil;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.nio.channels.ClosedChannelException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -33,6 +35,7 @@
import static io.netty.handler.codec.http3.Http3TestUtils.assertFrameReleased;
import static io.netty.handler.codec.http3.Http3TestUtils.assertFrameSame;
import static io.netty.handler.codec.http3.Http3TestUtils.verifyClose;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -48,6 +51,25 @@ public Http3ControlStreamInboundHandlerTest() {
super(QuicStreamType.UNIDIRECTIONAL, false, false);
}

@Test
public void testStreamInactiveFailuresDoNotFillInStackTrace() {
// These are static, so they must not populate a (native) backtrace: doing so would pin the Classloader of
// whatever thread happened to trigger the class initialization
// (see https://github.com/netty/netty/issues/17128).
assertNoStackTrace(Http3ControlStreamInboundHandler.ENCODER_STREAM_INACTIVE);
assertNoStackTrace(Http3ControlStreamInboundHandler.DECODER_STREAM_INACTIVE);
}

private static void assertNoStackTrace(ClosedChannelException cause) {
StackTraceElement[] before = cause.getStackTrace();
assertEquals(1, before.length);
assertEquals("streamClosed()", before[0].getMethodName());

// fillInStackTrace() must be a no-op; otherwise it would repopulate the backtrace with native frames.
cause.fillInStackTrace();
assertArrayEquals(before, cause.getStackTrace());
}

static Collection<Object[]> testData() {
List<Object[]> config = new ArrayList<>();
for (int a = 0; a < 2; a++) {
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.