elasticsearch/elasticsearch — pull request #7628 by rmuir (2014-09-06 13:35:10+00:00)
Title: add logging/safety when deleting files

File.delete() is not great as it just returns a boolean if it succeeds or fails.

Instead we can use Files.delete/Files.deleteIfExists, which throws a real exception when it fails (e.g. DirectoryNotEmptyException, Access Denied, etc)

Brings in helpers from lucene (temporarily as XIOUtils):
* deleteFilesIfExist(File...): removes all the files, throwing the first exception with suppressions for other exceptions, but always attempts to remove all files
* deleteFilesIgnoringExceptions(File...): removes all files, suppressing all exceptions. good for when handling other exceptions
* rm(File...): recursive removal of all files, on any failure throws exception that contains each file name and the exception it hit.

Bans File.delete() with forbidden APIs.

This is also an opportunity to review all places in the codebase where we delete files, since they are all touched in this PR.