slachiewicz opened a new pull request, #12814:
URL: https://github.com/apache/maven/pull/12814

   Fixes #12761. A `mvn` start can hang before printing anything, with no 
Java-level deadlock reported.
   
   `MessageUtils.systemInstall` publishes the `FastTerminal` immediately and 
builds the real terminal on `fast-terminal-thread`. Every `FastTerminal` method 
delegates through `getTerminal()`, which waits on the future that thread 
completes, so a single log statement from that thread parks it on its own 
result. `main` then parks behind it in `activateLogging`.
   
   The trigger arrived with the rc-6 JLine 3.30.6 → 4.3.1 bump: JLine 4.x 
initialises its native loader during provider probing and logs a JUL warning 
when a library candidate fails `System.load`, by which time `activateLogging` 
has bridged JUL to SLF4J. The load failure itself is harmless — JLine recovers 
by extracting the bundled library.
   
   Two details shaped the fix. The hazard window covers the consumer as well, 
since `consumer.accept(term)` runs before `terminal.complete(term)`. And one 
log statement reaches the terminal twice, through 
`MavenSimpleLogger.renderLevel` → `toAnsi` → `getType()` and again through 
`write` → the log sink installed in `createTerminal` → `terminal.writer()`, so 
guarding the message builder alone moves the hang rather than removing it. The 
guard therefore sits in `getTerminal()` and hands the building thread a dumb 
stand-in, which unblocks every delegating method at once. Rendering degrades to 
unstyled text while the build is in flight, which is what a dumb terminal would 
produce anyway.
   
   Throwing on re-entry instead was rejected: the exception escapes through the 
JUL handler and aborts JLine's fallback chain, turning a recoverable warning 
into a failed startup.
   
   Verified: three tests in `maven-jline`, one per entry path. With the guard 
removed each fails at 30 s; with it they pass in 0.5 s.
   
   `maven-4.0.x` carries the same code and the same JLine version. The CI 
symptom is apache/maven-executor#38.
   
   *This change was created with AI assistance.*
   


-- 
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]

Reply via email to