Skip to content

fix: do not follow symbolic links or directory junctions when deleting (#1169) - #1248

Open
Mikkey-f wants to merge 2 commits into
apache:mainfrom
Mikkey-f:fix/1169-delete-no-follow-links
Open

Mikkey-f wants to merge 2 commits into
apache:mainfrom
Mikkey-f:fix/1169-delete-no-follow-links

Conversation

@Mikkey-f

Copy link
Copy Markdown
Contributor

Purpose of the pull request

Closed: #1169. Supersedes #1170.

CompatibilityTest#readWithCacheAfterTempDeletion deleted the whole system temp directory, and FileUtils.delete followed symbolic links during its recursive walk, so a link inside the deleted tree could take the deletion outside it (see #1169 for the macOS incident).

This PR is based on @AhmedYoussef98's work in #1170, with their commit kept and authorship intact. It adds the Windows directory-junction guard requested in review: junctions are not symbolic links, so Files.isSymbolicLink() misses them while File.isDirectory() still resolves them.

What's changed?

Verification

  • Red/green on Windows 11 + JDK 17: with the junction guard removed, the new test fails with expected: <true> but was: <false> (the target file was deleted); with the guard in place it passes.
  • mvn clean package -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet: 60 common + 1,726 sheet tests, 0 failures, 1 skipped. The skip is the POSIX symlink test, which this Windows machine cannot create links for; CI's Linux runners execute it.
  • ./mvnw spotless:check and mvn javadoc:javadoc pass.

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

AhmedYoussef98 and others added 2 commits October 25, 2026 15:53
FileUtils.delete inspected the path through the File API, so a Windows
directory junction was seen as a directory and the recursive delete
followed it into the target. Read BasicFileAttributes with NOFOLLOW_LINKS
and delete symbolic links and junctions as leaf entries instead.

Add a Windows-only regression test that creates a junction with mklink /J
and verifies the target is left untouched.
@Mikkey-f
Mikkey-f force-pushed the fix/1169-delete-no-follow-links branch from bbd08cd to 3433cc0 Compare October 25, 2026 08:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CompatibilityTest deletes the whole system temp dir, and FileUtils.delete follows symlinks out of it

2 participants