From c371bf53714bf3856244592e2f464db7133308c4 Mon Sep 17 00:00:00 2001 From: Johnathan Gilday Date: Tue, 30 Jan 2024 15:02:09 -0500 Subject: [PATCH 1/2] Ignore NoSuchFileException in TempDirectory Cleanup While walking the temp directory, the file walker may fail to visit a file that has been removed by another thread or process. In this case, JUnit should ignore the NoSuchFileException, because there's nothing to clean-up. --- .../java/org/junit/jupiter/engine/extension/TempDirectory.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java index 8b8df545f467..f165b2e55968 100644 --- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java +++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java @@ -338,6 +338,9 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { + if (exc instanceof NoSuchFileException) { + return CONTINUE; + } // IOException includes `AccessDeniedException` thrown by non-readable or non-executable flags resetPermissionsAndTryToDeleteAgain(file, exc); return CONTINUE; From ed397b463971ee3d0803c56a0d8caad436817ffa Mon Sep 17 00:00:00 2001 From: Johnathan Gilday Date: Tue, 30 Jan 2024 15:10:08 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20Update=20Release=20Notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add NoSuchFileException suppression to release notes. --- .../docs/asciidoc/release-notes/release-notes-5.11.0-M1.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.0-M1.adoc b/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.0-M1.adoc index 873c15d7c895..2bde0736d9d8 100644 --- a/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.0-M1.adoc +++ b/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.0-M1.adoc @@ -67,6 +67,8 @@ repository on GitHub. *** The same applies to other types of test methods (`@TestFactory`, `@ParameterizedTest`, etc.) as well as lifecycle methods (`@BeforeAll`, `@AfterAll`, `@BeforeEach`, and `@AfterEach`). +* `TempDir` suppresses `NoSuchFileException` when deleting files that may have been deleted + by another thread or process. [[release-notes-5.11.0-M1-junit-jupiter-deprecations-and-breaking-changes]] ==== Deprecations and Breaking Changes