Repository navigation
Restore the java.util.logging root handlers after an embedded execution - #68
Merged
Merged
Conversation
Maven 4 replaces the handlers of the java.util.logging root logger with jul-to-slf4j's SLF4JBridgeHandler. Embedded, that is the caller's JVM, and the handler's classes come from Maven's realm: after close(), every java.util.logging record of the caller fails with NoClassDefFoundError: org/slf4j/spi/LocationAwareLogger, which surefire reports as executionError (seen on Windows CI). Put back the root handlers the JVM had before each execution. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@slachiewicz Please assign appropriate label to PR according to the type of change. |
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.
CI on Windows has been failing with an
executionErrorinToolboxExecutorToolTest(#64, #65, Dependabot PRs such as #62):Maven 4's
LookupInvoker.activateLogging()removes the handlers of thejava.util.loggingroot logger and installs jul-to-slf4j'sSLF4JBridgeHandler(Maven 3.9 doesn't ship jul-to-slf4j). Run embedded, that root logger belongs to the caller's JVM, and the handler's classes come from Maven's class realm.EmbeddedMavenExecutorrestores stdin/stdout/stderr, the context class loader and the system properties after a run, but not the logging handlers. Once the realm is closed, the nextjava.util.loggingrecord in the JVM fails. Surefire reports that asexecutionErrorbecause it isn't tied to a test method. It only showed up on Windows because something in the test JVM logs throughjava.util.loggingthere after an embedded Maven 4 run; the leak itself happens on every OS.execute()now captures the root logger's handlers before the run and puts them back in itsfinallyblock, next to the other restores. It captures per execution, not in the constructor, so a change the caller makes between executions is kept (see E5 in #49).module-infogainsrequires java.logging.EmbeddedJulHandlersTestruns-vembedded on Maven 3 and Maven 4 and checks the root handlers after the execution and afterclose(), then logs throughjava.util.logging. Without the fix, the Maven 4 case fails on Linux too: the root handlers are[SLF4JBridgeHandler]instead of[ConsoleHandler], and with that check skipped, the log call throws theNoClassDefFoundErrorabove. With the fix,mvn verifyfor the module passes.Maven itself could also uninstall the handler when the invoker closes; until then, the executor protects its callers.
🤖 Generated with Claude Code