-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix handling of Windows junctions during temp dir cleanup #4301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Issue: #4299
|
Full stacktrace of the failing test on Windows: |
| public FileVisitResult visitFileFailed(Path file, IOException exc) { | ||
| if (exc instanceof NoSuchFileException) { | ||
| LOGGER.trace(exc, () -> "visitFileFailed: " + file); | ||
| if (exc instanceof NoSuchFileException && !Files.exists(file, LinkOption.NOFOLLOW_LINKS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 This line fixes #4299
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes the error, but it won't have deleted the junction, right?
Wouldn't it be possible to improve the implementation of fileOperations.delete() to not throw this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes the error, but it won't have deleted the junction, right?
It will be deleted by the call to resetPermissionsAndTryToDeleteAgain below.
Wouldn't it be possible to improve the implementation of
fileOperations.delete()to not throw this error?
FileOperations exists only so that it can be replaced in tests.
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java
Show resolved
Hide resolved
| if (isLink(dir)) { | ||
| delete(dir); | ||
| return SKIP_SUBTREE; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 This avoids following junctions and, potentially, deleting files outside of the temp dir. We need to delete them here because postVisitDirectory is not called after returning SKIP_SUBTREE.
This reverts commit a0363f7.
Overview
Issue: #4299
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@APIannotations