Skip to content

Fix #13362: restore the java.util.logging root handlers after an invocation - #13363

Open
slachiewicz wants to merge 1 commit into
masterfrom
gh-13362-restore-jul-root-handlers
Open

slachiewicz wants to merge 1 commit into
masterfrom
gh-13362-restore-jul-root-handlers

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

LookupInvoker.activateLogging() (since #12344 for #11683) removes the handlers of the java.util.logging root logger and installs SLF4JBridgeHandler, and nothing puts them back. When Maven runs inside another JVM (embedded, resident, ToolProvider), that root logger is the host's: its logging goes to Maven's SLF4J afterwards, and once Maven's realm is closed every java.util.logging record fails with NoClassDefFoundError: org/slf4j/spi/LocationAwareLogger. Details and the trace are in #13362.

invoke() already saves and restores the system properties and the context class loader; it now does the same for the root logger's handlers, in the same finally. The restore runs after the context is closed, so Maven's own close-time logging still goes through the bridge. Every invocation, resident ones included, goes through doInvoke() → activateLogging(), which installs the bridge again for the next run.

MavenInvokerTest.restoresJavaUtilLoggingRootHandlers puts a known ConsoleHandler on the root logger, runs validate, and checks that it is the only root handler afterwards. Without the fix it fails with expected: <ConsoleHandler> but was: <SLF4JBridgeHandler>. With the fix, all 767 maven-cli tests pass.

Fixes #13362. apache/maven-executor#68 works around the same issue on the executor side for released Maven 4 versions. Backport to maven-4.0.x: #13364.

🤖 Generated with Claude Code

…cation

activateLogging() replaces the handlers of the java.util.logging root
logger with SLF4JBridgeHandler and nothing put them back. When Maven runs
inside another JVM (embedded, resident, ToolProvider), the root logger is
that JVM's: its logging went to Maven's SLF4J, and once Maven's realm was
closed every java.util.logging record failed with NoClassDefFoundError:
org/slf4j/spi/LocationAwareLogger. invoke() now restores the handlers like
it restores the system properties and the context class loader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This comment was marked as resolved.

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.

Invocations leave SLF4JBridgeHandler installed on the java.util.logging root logger of the host JVM

3 participants