Skip to content

Auto-port 4.1: Mark LoggingHandlerTest with @Isolated to fix flaky build#16340

Merged
chrisvest merged 1 commit into
4.1from
auto-port-pr-16338-to-4.1
Feb 23, 2026
Merged

Auto-port 4.1: Mark LoggingHandlerTest with @Isolated to fix flaky build#16340
chrisvest merged 1 commit into
4.1from
auto-port-pr-16338-to-4.1

Conversation

@netty-project-bot
Copy link
Copy Markdown
Contributor

Auto-port of #16338 to 4.1
Cherry-picked commit: 4e38d60


Motivation:

As LoggingHandlerTest depends on static state we should better mark it as @Isolated so we not mess up the state sometimes by running test concurrently. Failing to do so can cause issues like:

2026-02-21T04:13:33.0279489Z [ERROR] io.netty.handler.logging.LoggingHandlerTest -- Time elapsed: 0.095 s <<< ERROR!
2026-02-21T04:13:33.0281038Z java.lang.ExceptionInInitializerError
2026-02-21T04:13:33.0282266Z 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2026-02-21T04:13:33.0284143Z 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
2026-02-21T04:13:33.0285193Z 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
2026-02-21T04:13:33.0286182Z 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
2026-02-21T04:13:33.0287200Z 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
2026-02-21T04:13:33.0288167Z 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
2026-02-21T04:13:33.0289364Z 	Suppressed: java.lang.NoClassDefFoundError: Could not initialize class io.netty.handler.logging.LoggingHandlerTest
2026-02-21T04:13:33.0290429Z 		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2026-02-21T04:13:33.0291123Z 		at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
2026-02-21T04:13:33.0291996Z 		at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085)
2026-02-21T04:13:33.0292740Z 		... 5 more
2026-02-21T04:13:33.0294696Z Caused by: java.lang.ClassCastException: class org.slf4j.helpers.SubstituteLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.helpers.SubstituteLogger and ch.qos.logback.classic.Logger are in unnamed module of loader 'app')
2026-02-21T04:13:33.0296729Z 	at io.netty.handler.logging.LoggingHandlerTest.<clinit>(LoggingHandlerTest.java:61)
2026-02-21T04:13:33.0297699Z 	... 6 more

Modifications:

Add @Isolated annotation to test class

Result:

No more test-failures

Motivation:

As LoggingHandlerTest depends on static state we should better mark it
as `@Isolated` so we not mess up the state sometimes by running test
concurrently. Failing to do so can cause issues like:

```
2026-02-21T04:13:33.0279489Z [ERROR] io.netty.handler.logging.LoggingHandlerTest -- Time elapsed: 0.095 s <<< ERROR!
2026-02-21T04:13:33.0281038Z java.lang.ExceptionInInitializerError
2026-02-21T04:13:33.0282266Z 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2026-02-21T04:13:33.0284143Z 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
2026-02-21T04:13:33.0285193Z 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
2026-02-21T04:13:33.0286182Z 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
2026-02-21T04:13:33.0287200Z 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
2026-02-21T04:13:33.0288167Z 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
2026-02-21T04:13:33.0289364Z 	Suppressed: java.lang.NoClassDefFoundError: Could not initialize class io.netty.handler.logging.LoggingHandlerTest
2026-02-21T04:13:33.0290429Z 		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2026-02-21T04:13:33.0291123Z 		at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
2026-02-21T04:13:33.0291996Z 		at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085)
2026-02-21T04:13:33.0292740Z 		... 5 more
2026-02-21T04:13:33.0294696Z Caused by: java.lang.ClassCastException: class org.slf4j.helpers.SubstituteLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.helpers.SubstituteLogger and ch.qos.logback.classic.Logger are in unnamed module of loader 'app')
2026-02-21T04:13:33.0296729Z 	at io.netty.handler.logging.LoggingHandlerTest.<clinit>(LoggingHandlerTest.java:61)
2026-02-21T04:13:33.0297699Z 	... 6 more
```

Modifications:

Add `@Isolated` annotation to test class

Result:

No more test-failures

(cherry picked from commit 4e38d60)
@chrisvest chrisvest added this to the 4.1.132.Final milestone Feb 23, 2026
@chrisvest chrisvest enabled auto-merge (squash) February 23, 2026 22:12
@chrisvest chrisvest merged commit 2c2e9b7 into 4.1 Feb 23, 2026
18 checks passed
@chrisvest chrisvest deleted the auto-port-pr-16338-to-4.1 branch February 23, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants