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 — Auto-port 4.1: Avoid classloader leak via ImmediateEventExecutor terminationFuture failure by netty-project-bot · Pull Request #18359 · netty/netty

Auto-port 4.1: Avoid classloader leak via ImmediateEventExecutor terminationFuture failure #18359

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 4.1 from auto-port-pr-18338-to-4.1
Nov 12, 2026

Uh oh!

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

Merged

Auto-port 4.1: Avoid classloader leak via ImmediateEventExecutor terminationFuture failure #18359

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
41ef645
Avoid classloader leak via ImmediateEventExecutor terminationFuture f…
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

There are no files selected for viewing

21 changes: 0 additions & 21 deletions 21 common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.netty.util.internal.ObjectUtil;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.ThreadExecutorMap;
import io.netty.util.internal.ThrowableUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;

Expand Down Expand Up @@ -324,24 +323,4 @@ public void run() {
}
}
}

private static final class StacklessUnsupportedOperationException extends UnsupportedOperationException {

private static final long serialVersionUID = -8060232216137960173L;

private StacklessUnsupportedOperationException() { }

// Override fillInStackTrace() so we not populate the backtrace via a native call and so leak the
// Classloader. As the GlobalEventExecutor.INSTANCE is a singleton and holds on to this exception via its
// terminationFuture, a populated backtrace would pin the Classloader of whatever thread happened to trigger
// the lazy initialization of INSTANCE (see https://github.com/netty/netty/issues/17128).
@Override
public Throwable fillInStackTrace() {
return this;
}

static StacklessUnsupportedOperationException newInstance(Class<?> clazz, String method) {
return ThrowableUtil.unknownStackTrace(new StacklessUnsupportedOperationException(), clazz, method);
}
}
}
4 changes: 2 additions & 2 deletions 4 common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ protected Boolean initialValue() throws Exception {
}
};

private final Future<?> terminationFuture = new FailedFuture<Object>(
GlobalEventExecutor.INSTANCE, new UnsupportedOperationException());
private final Future<?> terminationFuture = new FailedFuture<Object>(GlobalEventExecutor.INSTANCE,
StacklessUnsupportedOperationException.newInstance(ImmediateEventExecutor.class, "terminationFuture"));

private ImmediateEventExecutor() { }

Expand Down
42 changes: 42 additions & 0 deletions 42 common/src/main/java/io/netty/util/concurrent/StacklessUnsupportedOperationException.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2026 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.util.concurrent;

import io.netty.util.internal.ThrowableUtil;

/**
* The failure of the {@link EventExecutor#terminationFuture()} of executors that can't be terminated, such as
* {@link GlobalEventExecutor} and {@link ImmediateEventExecutor}.
*/
final class StacklessUnsupportedOperationException extends UnsupportedOperationException {

private static final long serialVersionUID = -8060232216137960173L;

private StacklessUnsupportedOperationException() { }

// Override fillInStackTrace() so we not populate the backtrace via a native call and so leak the
// Classloader. The executors are singletons that hold on to this exception via their terminationFuture, so a
// populated backtrace would pin the Classloader of whatever thread happened to trigger the lazy initialization
// of their INSTANCE (see https://github.com/netty/netty/issues/17128).
@Override
public Throwable fillInStackTrace() {
return this;
}

static StacklessUnsupportedOperationException newInstance(Class<?> clazz, String method) {
return ThrowableUtil.unknownStackTrace(new StacklessUnsupportedOperationException(), clazz, method);
}
}
44 changes: 44 additions & 0 deletions 44 common/src/test/java/io/netty/util/concurrent/ImmediateEventExecutorTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2026 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.util.concurrent;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;

public class ImmediateEventExecutorTest {

@Test
public void testTerminationFutureFailureDoesNotFillInStackTrace() {
// ImmediateEventExecutor.INSTANCE is a singleton that holds on to the failure of its terminationFuture for
// the lifetime of its Classloader, so that failure must not populate a (native) backtrace: doing so would
// pin the Classloader of whatever thread happened to trigger the lazy initialization of INSTANCE
// (see https://github.com/netty/netty/issues/17128).
Throwable cause = ImmediateEventExecutor.INSTANCE.terminationFuture().cause();
assertInstanceOf(UnsupportedOperationException.class, cause);

StackTraceElement[] before = cause.getStackTrace();
assertEquals(1, before.length);
assertEquals(ImmediateEventExecutor.class.getName(), before[0].getClassName());
assertEquals("terminationFuture", before[0].getMethodName());

// fillInStackTrace() must be a no-op; otherwise it would repopulate the backtrace with native frames.
cause.fillInStackTrace();
assertArrayEquals(before, cause.getStackTrace());
}
}
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.