Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
None
-
None
-
None
-
None
Description
From Matteo (https://reviews.apache.org/r/9416/diff/2/?file=258262#file258262line402):
looking at the source, it seems that checking the return value and throw an exception seems a good way to shoot ourselves in the foot. I've added that check in other places and not I'm regretting that...
because a return false doesn't really mean I'm not able to delete the file/dir.
maybe the file is already deleted by someone else, or renamed...
You want to throw an exception only if the file/dir is still there...
so if we don't trust that the API will provide an exception is case of failure
we should do something like
if (!fs.delete(workingDir, true)) { // Make sure that the dir is still there if (fs.exists(workingDir)) { throw new IOException("Unable to delete " + workingDir); } }
We can add the following method to FSUtils:
void delete(Path f, boolean recursive) throws IOException;