Avoid NPE if deleteDirectory fails to list files to clean up

This commit is contained in:
Ville Skyttä 2016-07-28 20:02:04 +03:00 committed by Clebert Suconic
parent 7a5d1434fb
commit f981dbd7cf
1 changed files with 9 additions and 4 deletions

View File

@ -63,10 +63,15 @@ public class FileUtil {
attempts++;
}
for (String file : files) {
File f = new File(directory, file);
if (!deleteDirectory(f)) {
logger.warn("Failed to clean up file: " + f.getAbsolutePath());
if (files == null) {
logger.warn("Could not list files to clean up in: " + directory.getAbsolutePath());
}
else {
for (String file : files) {
File f = new File(directory, file);
if (!deleteDirectory(f)) {
logger.warn("Failed to clean up file: " + f.getAbsolutePath());
}
}
}
}