Skip to content

Commit

Permalink
MacOSX WatchService check for null file in recursiveListFiles
Browse files Browse the repository at this point in the history
It's possible to have listFiles return a null in specific conditions (I believe if the directory is deleted).
This code should check for that before using the file variable.
  • Loading branch information
stevegury committed Aug 24, 2015
1 parent 0f325b0 commit 87a68e4
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ private Map<File, Long> createLastModifiedMap(File file) {

private static Set<File> recursiveListFiles(File file) {
Set<File> files = new HashSet<File>();
files.add(file);
if (file.isDirectory()) {
for (File child : file.listFiles()) {
files.addAll(recursiveListFiles(child));
if (file != null) {
files.add(file);
if (file.isDirectory()) {
for (File child : file.listFiles()) {
files.addAll(recursiveListFiles(child));
}
}
}
return files;
Expand Down

0 comments on commit 87a68e4

Please sign in to comment.