Skip to content

[cli] Fix hanging PmdCliTest under Windows with git bash - #7344

Merged
UncleOwen merged 1 commit into
pmd:mainfrom
adangel:fix-windows-progressbar-hang
Nov 13, 2026
Merged

UncleOwen merged 1 commit into
pmd:mainfrom
adangel:fix-windows-progressbar-hang

Conversation

@adangel

@adangel adangel commented Nov 13, 2026

Copy link
Copy Markdown
Member

Describe the PR

PmdCliTest hangs under Windows when the build runs in git bash. In the Windows CI build it
doesn't hang forever but takes about 9.5 minutes: Time elapsed: 568.8 s -- in PmdCliTest.

The progressbar uses JLine to find out the terminal width. In git bash, PWD and MSYSTEM
are set, so JLine uses its exec terminal provider. That provider runs tty.exe with the
inherited stdin of the forked surefire JVM. Surefire reads its command channel from that
stdin at the same time, so tty.exe doesn't start until that read completes. The thread dump
shows the ProgressBar thread waiting in ExecTerminalProvider.systemStreamName /
ExecHelper.waitAndCapture.

This happened before. In d1d10d1 it was worked around by
adding --no-progress to the default arguments of PmdCliTest. The test
reportsSummaryAfterProgressBarWithReportFile (added with #6823) needs the progress bar and
doesn't use these arguments, so the problem came back.

This PR disables JLine's exec provider for all pmd-cli tests via the system property
org.jline.terminal.exec=false. The tests don't need a real terminal. Running PMD itself in
git bash isn't affected.

Related issues

Ready?

  • Added unit tests for fixed bug/feature (existing test reportsSummaryAfterProgressBarWithReportFile)
  • Passing all unit tests (Windows CI job: PmdCliTest should take seconds instead of ~9.5 minutes)
  • Complete build ./mvnw clean verify passes (checked by GitHub Actions)
  • Added (in-code) documentation (if needed)

🤖 Generated with Claude Code

The progressbar uses JLine to determine the terminal width. Under
Windows in git bash (PWD and MSYSTEM are set), JLine uses the exec
terminal provider, which runs "tty.exe" with the inherited stdin of
the forked surefire JVM. As surefire is reading from stdin (command
channel) at the same time, tty.exe doesn't start until that read
completes. This made PmdCliTest hang (locally) or take about 9.5
minutes (in the Windows CI build).

This happened before and was worked around in d1d10d1 by adding
"--no-progress" to the standard arguments of PmdCliTest. The test
reportsSummaryAfterProgressBarWithReportFile (added with pmd#6823)
needs the progress bar and doesn't use these standard arguments, so
the problem came back.

The tests don't need a real terminal, so disable the exec provider
for all pmd-cli tests instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adangel adangel added the in:pmd-internals Affects PMD's internals label Nov 13, 2026
@adangel

adangel commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Btw. I was testing my local branch build (https://github.com/adangel/pmd/tree/wip/real-java-modules) under Windows and noticed, that the build is hanging in pmd-cli...

I've now waited long enough, it took ~20 minutes vs. 10 seconds. How long it hangs seems to be a race between tty.exe and surefire. The timings of the last builds are 477, 518, 569, 589, 625 and 637 s for the test PmdCliTest. So, it was not always 9.5 minutes.

@pmd-actions-helper

Copy link
Copy Markdown
Contributor

Documentation Preview

No relevant source code has been changed, pmdtester skipped.

(comment created at 2026-11-13 15:45:28+00:00 for 035fc85)

@adangel adangel added this to the 7.30.0 milestone Nov 13, 2026

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now it's back to 1.6s. Thanks!

@UncleOwen
UncleOwen merged commit f835461 into pmd:main Nov 13, 2026
12 checks passed
@adangel

adangel commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

The build for this PR now says

[INFO] Tests run: 44, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.608 s -- in PmdCliTest

While the last build from main shows:

[INFO] Tests run: 44, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 568.8 s -- in PmdCliTest

Seems to be working, yes :)

@adangel
adangel deleted the fix-windows-progressbar-hang branch November 13, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:pmd-internals Affects PMD's internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants