Skip to content

Commit b9761bb

Browse files
committed
Fix Checker Framework errors
1 parent 175bf5e commit b9761bb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/engineering/swat/watch/impl/jdk/JDKFileWatch.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ public class JDKFileWatch extends JDKBaseWatch {
5151
public JDKFileWatch(Path file, Executor exec, Consumer<WatchEvent> eventHandler) {
5252
super(file, exec, eventHandler);
5353

54-
this.parent = path.getParent();
55-
this.fileName = path.getFileName();
54+
// Use local variables to check null before field assignments (Checker
55+
// Framework doesn't like it the other way around)
56+
var parent = path.getParent();
57+
var fileName = path.getFileName();
5658
if (parent == null || fileName == null) {
5759
throw new IllegalArgumentException("The root path is not a valid path for a file watch");
5860
}
59-
6061
assert !parent.equals(path);
62+
63+
this.parent = parent;
64+
this.fileName = fileName;
6165
}
6266

6367
private void filter(WatchEvent event) {

0 commit comments

Comments
 (0)