Skip to content

fix: stop tests from deleting the system temp dir and FileUtils.delete from following symlinks - #1170

Open
AhmedYoussef98 wants to merge 1 commit into
apache:mainfrom
AhmedYoussef98:fix-temp-delete-symlink
Open

AhmedYoussef98 wants to merge 1 commit into
apache:mainfrom
AhmedYoussef98:fix-temp-delete-symlink

Conversation

@AhmedYoussef98

Copy link
Copy Markdown

Purpose of the pull request

Closed: #1169

What's changed?

  • CompatibilityTest#readWithCacheAfterTempDeletion now deletes only Fesod's own temp directory (FileUtils.getTempFilePrefix()) and no longer deletes the whole java.io.tmpdir. That is still what the test means to check: Fesod recovers when its temp and cache files are removed while idle. The system temp directory is shared with other processes, so a test must never delete it.
  • FileUtils.delete now deletes a symbolic link itself and does not follow it. Before, File.isDirectory()/listFiles() resolved links, so the recursive delete could leave the directory it was given. On macOS, an Applications -> /Applications link inside a mounted installer DMG under $TMPDIR led it to wipe application bundles (details in [Bug] CompatibilityTest deletes the whole system temp dir, and FileUtils.delete follows symlinks out of it #1169).
  • Adds FileUtilsTest#test_delete_doesNotFollowSymbolicLinks. It fails on current main (the link target's contents are deleted) and passes with this change. It is skipped where symbolic links can't be created.

Verified with ./mvnw package -Dmaven.test.skip=false -Dtest='FileUtilsTest,CompatibilityTest' -pl fesod-common,fesod-shaded,fesod-sheet (27 tests, all passing) and ./mvnw spotless:check.

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.

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

1 participant