|
33 | 33 | import java.nio.file.attribute.BasicFileAttributes; |
34 | 34 | import java.nio.file.attribute.FileTime; |
35 | 35 | import java.util.ArrayDeque; |
| 36 | +import java.util.Collections; |
36 | 37 | import java.util.Deque; |
37 | 38 | import java.util.HashSet; |
38 | 39 | import java.util.Map; |
|
42 | 43 |
|
43 | 44 | import org.apache.logging.log4j.LogManager; |
44 | 45 | import org.apache.logging.log4j.Logger; |
| 46 | +import org.checkerframework.checker.nullness.qual.KeyFor; |
45 | 47 | import org.checkerframework.checker.nullness.qual.Nullable; |
46 | 48 |
|
47 | 49 | import engineering.swat.watch.WatchEvent; |
@@ -92,9 +94,9 @@ private static class Index { |
92 | 94 | return nested == null ? null : nested.get(fileName); |
93 | 95 | } |
94 | 96 |
|
95 | | - public @Nullable Set<Path> getFileNames(Path parent) { |
| 97 | + public Set<Path> getFileNames(Path parent) { |
96 | 98 | var nested = lastModifiedTimes.get(parent); |
97 | | - return nested == null ? null : nested.keySet(); |
| 99 | + return nested == null ? Collections.emptySet() : (Set<Path>) nested.keySet(); |
98 | 100 | } |
99 | 101 |
|
100 | 102 | public @Nullable FileTime remove(Path p) { |
@@ -214,10 +216,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO |
214 | 216 | @Override |
215 | 217 | public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { |
216 | 218 | // Issue `DELETED` events based on the set of paths visited in `dir` |
217 | | - var indexedInDir = index.getFileNames(dir); |
218 | 219 | var visitedInDir = visited.pop(); |
219 | | - if (indexedInDir != null && visitedInDir != null) { |
220 | | - for (var p : indexedInDir) { |
| 220 | + if (visitedInDir != null) { |
| 221 | + for (var p : index.getFileNames(dir)) { |
221 | 222 | if (!visitedInDir.contains(p)) { |
222 | 223 | var fullPath = dir.resolve(p); |
223 | 224 | // The index may have been updated during the visit, so |
|
0 commit comments