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

   ## Summary
   
   - Fix ANSI escape codes appearing in piped/redirected output on JDK 22+ 
(reported with JDK 25)
   - Since JDK 22, `System.console()` always returns non-null even when stdout 
is piped, causing JLine's `ForcedSysOut` terminal to bypass TTY detection
   - Add explicit pipe/redirection detection using `Console.isTerminal()` (JDK 
22+, via reflection) in the auto color mode logic
   
   ## Root Cause
   
   When using auto color detection with `ForcedSysOut`, JLine always returns 
`SystemStream.Output` without checking if stdout is actually a TTY. On JDK 21, 
the exec/JNI terminal providers would fail to create a system terminal when 
stdout was piped, falling back to a dumb terminal. On JDK 22+ with the FFM 
provider, the terminal is created successfully (stdin is still a TTY), 
resulting in a non-dumb terminal and colored output even when piped.
   
   ## Test plan
   
   - [ ] `mvn help:help -X | less` should show plain text (no ANSI codes) on 
JDK 25+
   - [ ] `mvn help:help -X > /tmp/out.txt` should produce plain text on JDK 25+
   - [ ] `mvn help:help -X` should still show colored output on a real terminal
   - [ ] `mvn --color=always help:help -X | less` should still show ANSI codes 
(forced)
   - [ ] `mvn --color=never help:help -X` should show plain text
   - [ ] Behavior unchanged on JDK 17/21
   
   Fixes #11885
   
   _Claude Code on behalf of Guillaume Nodet_
   
   🤖 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