From ca4ee96da12c964539020f13466d994ae6f90a90 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Fri, 24 Jul 2026 16:28:01 +0200 Subject: [PATCH] Fix Windows flake in CommandChannelDecoderTest 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 --- .../booter/spi/CommandChannelDecoderTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/spi/CommandChannelDecoderTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/spi/CommandChannelDecoderTest.java index 74e9d5e4bc..38edf914b1 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/spi/CommandChannelDecoderTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/spi/CommandChannelDecoderTest.java @@ -25,7 +25,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.nio.file.Path; import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; @@ -37,7 +36,6 @@ import org.apache.maven.surefire.booter.ForkedNodeArg; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; import static java.nio.channels.Channels.newChannel; import static java.nio.charset.StandardCharsets.UTF_8; @@ -63,12 +61,13 @@ public class CommandChannelDecoderTest { private static final Random RND = new Random(); - @TempDir - Path tempFolder; - @BeforeEach public void initTmpFile() { - File reportsDir = tempFolder.toFile(); + // Not a JUnit @TempDir: the decoder writes .dumpstream files into this directory, + // and on Windows a freshly written file can be transiently locked (antivirus, + // indexer) right when the @TempDir cleanup runs, failing the whole test class + // with DirectoryNotEmptyException. target/ needs no post-test cleanup. + File reportsDir = new File("target", "decoder-dumps"); String dumpFileName = "surefire-" + RND.nextLong(); DumpErrorSingleton.getSingleton().init(reportsDir, dumpFileName); }