Skip to content

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

Description

@slachiewicz

Affected version

4.0.0-rc-7, master (since #12344 for #11683)

Bug description

LookupInvoker.activateLogging() removes all handlers of the java.util.logging root logger and installs jul-to-slf4j's SLF4JBridgeHandler, and nothing puts the old handlers back. That is fine for mvn run as a process, but the invoker also runs inside other JVMs: embedded (maven-executor's EmbeddedMavenExecutor, ITs), resident invokers, and the ToolProvider. There the root logger belongs to the host JVM, and the handler's classes come from Maven's class realm:

  • after the invocation, the host's java.util.logging output goes to Maven's SLF4J instead of its own handlers (a ConsoleHandler is gone);
  • once the realm is closed, every java.util.logging record of the host fails:
java.lang.NoClassDefFoundError: org/slf4j/spi/LocationAwareLogger
	at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:312)
	at java.logging/java.util.logging.Logger.log(Logger.java:962)
Caused by: java.lang.ClassNotFoundException: org.slf4j.spi.LocationAwareLogger
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)

This fails apache/maven-executor's Windows CI as a surefire executionError (for example on apache/maven-executor#64). To reproduce, run Maven 4.0.0-rc-7 embedded (EmbeddedMavenExecutor, -v), close the executor, then log through java.util.logging.

LookupInvoker.invoke() already saves and restores the system properties and the context class loader around an invocation; the root logger's handlers should get the same treatment. apache/maven-executor#68 works around it on the executor side for released Maven 4 versions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions