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

   ## Summary
   
   Fixes Maven 4.0.0-rc-6 hanging on startup with JDK 25 in Linux container 
environments, and fixes a flaky 
`FastTerminalReentrancyTest.usingTheTerminalFromTheConsumerDoesNotDeadlock` 
deadlock observed across JDK 17/21/25 on ubuntu CI runners 
([example](https://github.com/apache/maven/actions/runs/33240711857/job/99092450601?pr=12913),
 [example](https://github.com/apache/maven/actions/runs/33258097527), 
[example](https://github.com/apache/maven/actions/runs/33255877185)).
   
   **Root cause:** `FastTerminal` only guarded `writer()` and `getType()` 
against build-thread reentrancy. JLine 4.4.0's FFM provider initialization 
(`CLibrary.<clinit>`) and `AnsiConsole.systemInstall()` can reach back through 
other terminal methods (`getSize`, `getName`, `encoding`, etc.) on the build 
thread, causing a deadlock where the build thread waits on the 
`CompletableFuture` it is itself computing.
   
   **Fix:** Move the `isBuildThreadWaitingOnItself()` guard into 
`getTerminal()` — the single choke point all delegate methods pass through — 
backed by a pre-built `DumbTerminal`. This covers all methods at once, 
including any new ones JLine may add.
   
   **Improvements over #12921:**
   - The `DumbTerminal`'s output stream is wrapped with `FilterOutputStream` so 
that `close()` flushes instead of closing the captured `System.err` — 
`DumbTerminal.doClose()` cascades to its writer's underlying stream, and 
closing `System.err` would silently break stderr for the process
   - Removed the now-redundant per-method guards on `writer()` and `getType()`, 
along with the unused `fallbackWriter` field and `fallbackWriter()` method — 
the single guard in `getTerminal()` makes them dead code
   
   ## Test plan
   
   - [x] Existing tests for `writer()` and `getType()` still pass (4 tests, 
10/10 stress runs)
   - [x] New test `arbitraryTerminalMethodsFromTheBuilderDoNotDeadlock` 
verifies `getSize()` from the builder callback
   - [x] New test `arbitraryTerminalMethodsFromTheConsumerDoNotDeadlock` 
verifies `getName()` from the consumer callback
   - [ ] CI passes on all platforms
   
   Supersedes #12921.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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