Skip to content

Fix #11885: Disable ANSI colors when stdout is piped on JDK 22+ (backport)#12111

Merged
gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:backport/maven-4.0.x/pr-11887
May 19, 2026
Merged

Fix #11885: Disable ANSI colors when stdout is piped on JDK 22+ (backport)#12111
gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:backport/maven-4.0.x/pr-11887

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 19, 2026

Backport of #11887 to maven-4.0.x.

Summary

  • Change ForcedSysOut to SysOut in JLine's TerminalBuilder configuration so that JLine properly checks whether stdout is a TTY before creating a system terminal
  • On JDK 22+ with the FFM provider, ForcedSysOut caused ANSI escape codes in piped output because stdin being a TTY was enough to create a non-dumb terminal

Fixes #11885

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet added this to the 4.0.0-rc-6 milestone May 19, 2026
…ted on JDK 22+ (apache#11887)

Change ForcedSysOut to SysOut so that JLine properly checks whether
stdout is a TTY before creating a system terminal. ForcedSysOut
bypasses this check, which causes JLine to create a non-dumb terminal
even when stdout is piped (since stdin is still a TTY), resulting in
ANSI escape codes appearing in piped output on JDK 22+ where the FFM
provider successfully creates a terminal from stdin alone.

With SysOut, JLine detects that stdout is not a TTY and falls back to
a dumb terminal, correctly disabling ANSI colors.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet force-pushed the backport/maven-4.0.x/pr-11887 branch from 7dd117b to c9426e3 Compare May 19, 2026 19:58
@gnodet gnodet merged commit 9c8a1ef into apache:maven-4.0.x May 19, 2026
1 check passed
@github-actions
Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant