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

   ## Summary
   
   Forward port of #12961 to master.
   
   Fixes a race condition introduced in #12921: the `FastTerminal` constructor 
started its build thread before returning, so `MessageUtils.terminal` was still 
`null` when the build thread ran the builder callback — a race between the 
constructor returning and the thread scheduling. This caused a 
`NullPointerException` in CI 
([example](https://github.com/apache/maven/actions/runs/33327782193/job/99318899899)):
   
   ```
   NullPointerException: Cannot invoke "org.jline.terminal.Terminal.getSize()" 
because "t" is null
   ```
   
   The fix splits construction from start: `MessageUtils` now assigns the field 
**before** calling `FastTerminal.start()`, and `Thread.start()` provides the 
happens-before edge that makes the assignment visible to the build thread 
without additional synchronization.
   
   - `FastTerminal`: extract `start()` method from constructor, document the 
publish-before-start contract  
   - `MessageUtils.systemInstall()`: assign `terminal` field, then call 
`start()`  
   - New test `terminalAssignmentIsVisibleFromBuilderCallback` that asserts 
`MessageUtils.getTerminal()` is non-null from the builder callback
   
   ## Test plan
   
   - [x] `FastTerminalReentrancyTest` — all 5 tests pass (4 existing + 1 new)
   - [x] Full `maven-jline` module test suite passes
   - [ ] CI validates on Java 17/21/25
   
   
   🤖 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