Repository navigation
Fix #13362: restore the java.util.logging root handlers after an invocation - #13363
Open
slachiewicz wants to merge 1 commit into
Open
slachiewicz wants to merge 1 commit into
slachiewicz wants to merge 1 commit into
Conversation
…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>
gnodet
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
LookupInvoker.activateLogging()(since #12344 for #11683) removes the handlers of thejava.util.loggingroot logger and installsSLF4JBridgeHandler, 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 everyjava.util.loggingrecord fails withNoClassDefFoundError: 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 samefinally. 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 throughdoInvoke()→activateLogging(), which installs the bridge again for the next run.MavenInvokerTest.restoresJavaUtilLoggingRootHandlersputs a knownConsoleHandleron the root logger, runsvalidate, and checks that it is the only root handler afterwards. Without the fix it fails withexpected: <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