FileUtils#forceDelete should use Files#delete rather than
File#delete so exception messages includes reason for failure.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -152,6 +152,9 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="IO-633" dev="ggregory" type="add" due-to="Gary Gregory">
Add DeletingFileVisitor.
</action>
+ <action issue="IO-629" dev="ggregory" type="update" due-to="Ian Springer, Ian Springer, Gary Gregory">
+ FileUtils#forceDelete should use Files#delete rather than File#delete so exception messages includes reason for failure.
+ </action>
</release>
<release version="2.6" date="2017-10-15" description="Java 7 required, Java 9 supported.">

MODIFY
src/main/java/org/apache/commons/io/FileUtils.java
src/main/java/org/apache/commons/io/FileUtils.java
@@ -1333,15 +1333,14 @@ private static void doCopyFile(final File srcFile, final File destFile, final bo
* @throws IOException in case deletion is unsuccessful
*/
public static void forceDelete(final File file) throws IOException {
- Counters.PathCounters deleteCounter;
+ final Counters.PathCounters deleteCounters;
try {
- deleteCounter = PathUtils.delete(file.toPath());
+ deleteCounters = PathUtils.delete(file.toPath());
} catch (IOException e) {
- final String message = "Unable to delete file: " + file;
- throw new IOException(message, e);
+ throw new IOException("Unable to delete file: " + file, e);
}
- if(deleteCounter.getFileCounter().get() < 1 && deleteCounter.getDirectoryCounter().get() < 1) {
+ if (deleteCounters.getFileCounter().get() < 1 && deleteCounters.getDirectoryCounter().get() < 1) {
// didn't find a file to delete.
throw new FileNotFoundException("File does not exist: " + file);
}

[IO-629] FileUtils#forceDelete should use Files#delete rather than
File#delete so exception messages includes reason for failure.