boris-unckel edited a comment on pull request #187:
URL: https://github.com/apache/commons-io/pull/187#issuecomment-761536421
@garydgregory
Now it fails again in deleteDirectory (which is not the cause)
`Error:
org.apache.commons.io.FileUtilsDeleteDirectoryLinuxTestCase.testDeleteInvalidLinks
Time elapsed: 0.003 s <<< ERROR!
java.nio.file.DirectoryNotEmptyException:
/tmp/junit16834268871756684963/realParentDirC
at
java.base/sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:247)
at
java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105)
at java.base/java.nio.file.Files.delete(Files.java:1141)
at org.apache.commons.io.FileUtils.delete(FileUtils.java:1170)
at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1189)
at
org.apache.commons.io.FileUtilsDeleteDirectoryBaseTestCase.testDeleteInvalidLinks(FileUtilsDeleteDirectoryBaseTestCase.java:216)`
IMO This stacktrace is misleading because originally forceDelete fails to
delete the broken link. It's in the DeletingPathVisitor.visitFile:
For the broken link "linkToB" Files.exists(file, linkOptions) returns false.
For regular links and regular files it returns true.
FileUtils.forceDelete does
`deleteCounters = PathUtils.delete(file.toPath(),
PathUtils.EMPTY_LINK_OPTION_ARRAY,
StandardDeleteOption.OVERRIDE_READ_ONLY);`
but `Files.exists(file, linkOptions)` needs
`PathUtils.NOFOLLOW_LINK_OPTION_ARRAY` to recognize the broken link exists.
A change in forceDelete will not help - this causes (a) destinations of
links deleted and (b) a NoSuchFileException later, because a broken link does
not point to a file.
What do you suggest?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]