Skip to content

Commit ff486cf

Browse files
gildaymarcphilipp
authored andcommitted
Ignore NoSuchFileException in TempDir cleanup (#3667)
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. (cherry picked from commit 6dbc84e)
1 parent b9d40b2 commit ff486cf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

documentation/src/docs/asciidoc/release-notes/release-notes-5.10.3.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ on GitHub.
3232

3333
==== Bug Fixes
3434

35-
* ❓
35+
* `TempDir` suppresses `NoSuchFileException` when deleting files that may have been deleted
36+
by another thread or process.
3637

3738
==== Deprecations and Breaking Changes
3839

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
338338

339339
@Override
340340
public FileVisitResult visitFileFailed(Path file, IOException exc) {
341+
if (exc instanceof NoSuchFileException) {
342+
return CONTINUE;
343+
}
341344
// IOException includes `AccessDeniedException` thrown by non-readable or non-executable flags
342345
resetPermissionsAndTryToDeleteAgain(file, exc);
343346
return CONTINUE;

0 commit comments

Comments
 (0)