Skip to content

Fix Windows flake in CommandChannelDecoderTest#3400

Open
ascheman wants to merge 1 commit into
apache:masterfrom
aschemaven:bugfix/decoder-test-dump-tempdir-win
Open

Fix Windows flake in CommandChannelDecoderTest#3400
ascheman wants to merge 1 commit into
apache:masterfrom
aschemaven:bugfix/decoder-test-dump-tempdir-win

Conversation

@ascheman

Copy link
Copy Markdown

Verify / windows-latest jdk-8 intermittently fails whole CommandChannelDecoderTest runs with:

org.junit.platform.commons.JUnitException: Failed to close extension context
Caused by: java.io.IOException: Failed to delete temp directory C:\...\Temp\junit-...
  Suppressed: java.nio.file.DirectoryNotEmptyException

Observed three times within a week on unrelated PRs (#3392, #3395 — e.g. https://github.com/apache/maven-surefire/actions/runs/30089175667/job/89469589427 and run 30089211662); every re-run is green.

Root cause: the test class initializes DumpErrorSingleton into the JUnit @TempDir, and several tests write .dumpstream files there. On Windows a freshly written file can be transiently locked (antivirus/indexer) exactly when the @TempDir cleanup runs — the cleanup throws and fails the whole class. Surefire's own I/O is fine (all dump writes use try-with-resources), and JUnit 5.14's resilient cleanup retries evidently do not close the gap.

Fix: write the dumps under target/decoder-dumps/ instead — no post-test cleanup needed at all, mvn clean removes them, and the files remain inspectable after CI runs. CommandChannelDecoderTest is the only test class using this pattern.


🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates Surefire Booter unit tests to avoid intermittent Windows temp-directory cleanup failures by moving dumpstream output out of JUnit’s @TempDir and into the module’s target/ directory, where it won’t be deleted as part of per-test cleanup.

Changes:

  • Remove JUnit @TempDir usage from CommandChannelDecoderTest.
  • Initialize DumpErrorSingleton to write dump files under target/decoder-dumps/ to avoid Windows file-lock timing issues during temp cleanup.
  • Add in-code rationale describing the Windows flake and why target/ is used instead.

Comment on lines 64 to +66
@BeforeEach
public void initTmpFile() {
File reportsDir = tempFolder.toFile();
// Not a JUnit @TempDir: the decoder writes .dumpstream files into this directory,
@ascheman ascheman self-assigned this Jul 24, 2026
@ascheman ascheman added the bug Something isn't working label Jul 24, 2026
The test initializes DumpErrorSingleton into the JUnit @tempdir;
several tests write .dumpstream files there. On Windows a freshly
written file can be transiently locked (antivirus, indexer) right when
the @tempdir cleanup runs, failing the whole class with
DirectoryNotEmptyException ('Failed to close extension context').
JUnit 5.14's resilient cleanup retries do not close the gap. Writing
the dumps under target/ needs no post-test cleanup at all.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ascheman
ascheman force-pushed the bugfix/decoder-test-dump-tempdir-win branch from 48fb918 to ca4ee96 Compare July 24, 2026 14:55
@ascheman ascheman changed the title Fix windows flake: decoder test dumps out of @TempDir Fix Windows flake in CommandChannelDecoderTest Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants