[
https://issues.apache.org/jira/browse/IO-859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876112#comment-17876112
]
JD Dean commented on IO-859:
----------------------------
Hi Gary,
My expection is based on the documentation, which says that forceDelete says
will throw FileNotFoundException if the file is not found. In addition, the
IOException message is misleading/confusing.
The current behavior is a departure from the way this used to work (I'm fixing
a bug in someone else's code that worked with 2.11.0 but fails with 2.16.1).
Our code (which probably pre-dates 2.11.0) was catching NoSuchFileException. If
I had to make a guess, I'd say that an earlier version of forceDelete was
throwing NoSuchFileException, then was changed (intentionally or not) so that
no exception was thrown for a missing file (in or before 2.11.0).
Someone needs to decide on how forceDelete is supposed to handle this
situation. My suggestion is to restore the 2.11.0 behavior, namely do not throw
an exception for a missing file, and update the documentation by removing the
note about FileNotFoundException.
> FileUtils.forceDelete on non-existent file on Windows throws IOException
> rather than FileNotFoundException
> ----------------------------------------------------------------------------------------------------------
>
> Key: IO-859
> URL: https://issues.apache.org/jira/browse/IO-859
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.16.1
> Environment: Windows
> Reporter: JD Dean
> Priority: Minor
>
> using FileUtils.forceDelete on a non-existent file throws *IOException: DOS
> or POSIX file operations not available* in setReadOnly.
> {code:java}
> Caused by: java.io.IOException: DOS or POSIX file operations not available
> for <path>
> PathUtils.setReadOnly(PathUtils.java:1602)
> PathUtils.deleteFile(PathUtils.java:584)
> PathUtils.delete(PathUtils.java:477)
> FileUtils.forceDelete(FileUtils.java:1386)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)