gnodet-bot commented on code in PR #12694:
URL: https://github.com/apache/maven/pull/12694#discussion_r4281689891
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java:
##########
@@ -314,6 +316,20 @@ protected void configureLogging(C context) throws
Exception {
} else if (context.options().quiet().orElse(false)) {
context.loggerLevel = Slf4jConfiguration.Level.ERROR;
context.slf4jConfiguration.setRootLoggerLevel(context.loggerLevel);
+ // Install the JUL handler early and clamp the JUL root to SEVERE
+ // so that JLine terminal-init DEBUG events (emitted via
java.util.logging
+ // before activateLogging() runs) are suppressed at source.
+ // createTerminal() executes after configureLogging() but before
+ // activateLogging(), so without this guard those DEBUG lines leak
+ // into the build output even when -q is in effect, causing
+ // MavenITmng4387QuietLoggingTest to fail on Windows.
+ // Setting SEVERE here is safe: it only blocks events, so it
+ // cannot trigger the SLF4J-bootstrap reentrancy flood that
+ // Level.ALL would cause.
+ if (!MavenJulHandler.isInstalled()) {
+ MavenJulHandler.install();
+ }
+ LogManager.getLogManager().getLogger("").setLevel(Level.SEVERE);
Review Comment:
**[medium] JUL root logger level is set but never restored — leaks to host
JVM in embedded scenarios**
This PR introduces two `setLevel()` calls on the JUL root logger:
- `configureLogging()` quiet mode: `getLogger("").setLevel(Level.SEVERE)`
(here, line 332)
- `activateLogging()`: `getLogger("").setLevel(julRootLevel)` (line 511)
`restoreRootLoggerHandlers` (and the `invoke()` finally block) restores the
old handlers but not the old level. In embedded-Maven scenarios (IDE plugin,
another JVM host), the level change leaks: quiet mode leaves the root
permanently at `SEVERE`, silently swallowing the host's `INFO`/`WARNING` JUL
output after Maven returns.
Fix: capture the old level before invocation and restore it in the finally
block.
In `invoke()`, alongside `oldRootLoggerHandlers`, add:
```java
java.util.logging.Level oldRootLoggerLevel =
java.util.logging.Logger.getLogger("").getLevel();
```
Then in the `finally` block:
```java
java.util.logging.Logger.getLogger("").setLevel(oldRootLoggerLevel);
restoreRootLoggerHandlers(oldRootLoggerHandlers);
```
--
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]