SebTardif opened a new pull request, #4520: URL: https://github.com/apache/logging-log4j2/pull/4520
## Summary `LoggerContext.start(Configuration)` registers the JVM shutdown hook before `setConfiguration` installs that configuration. The hook copied `shutdownTimeoutMillis` from the `DefaultConfiguration` still in place, which is 0. `ExecutorServices.shutdown` does not wait when the timeout is 0, so a configured `shutdownTimeout` was ignored on JVM exit. `start()` with no arguments still calls `reconfigure()` first and then registers the hook, so that path already used the installed configuration. `AsyncLoggerContext.start(Configuration)` calls `super.start(config)` and picks up this change. On `2.x`, `start(Configuration)` calls `reconfigure(config)` before the hook is registered, so this regression is on `main` only. Introduced when `setConfiguration(config)` stayed after the hook registration (`02560820ef`, Ralph Goers, 2013) and the timeout snapshot was added in `705e27253c` (Mikael Staldal, 2016). The Log4j 3 reorder never moved the snapshot onto the configuration argument. ## Test plan - [x] Red: `LoggerContextShutdownHookTimeoutTest` against unfixed `log4j-core` failed with `expected: <5000> but was: <0>` - [x] Green: the same test passed after the fix - [x] `./mvnw -pl log4j-core,log4j-core-test spotless:apply` ``` export JAVA_HOME=$(/usr/libexec/java_home -v 17) ./mvnw -pl log4j-core install -DskipTests ./mvnw -pl log4j-core-test test -Dtest=LoggerContextShutdownHookTimeoutTest -Dsurefire.failIfNoSpecifiedTests=false ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
