File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
src/main/java/engineering/swat/watch Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 2828
2929import java .nio .file .Path ;
3030
31+ import org .checkerframework .checker .nullness .qual .Nullable ;
32+
3133/**
3234 * The library publishes these events to all subscribers, they are immutable and safe to share around.
3335 */
@@ -67,13 +69,13 @@ public enum Kind {
6769 private final Path relativePath ;
6870
6971 public WatchEvent (Kind kind , Path rootPath ) {
70- this (kind , rootPath , Path . of ( "" ) );
72+ this (kind , rootPath , null );
7173 }
7274
73- public WatchEvent (Kind kind , Path rootPath , Path relativePath ) {
75+ public WatchEvent (Kind kind , Path rootPath , @ Nullable Path relativePath ) {
7476 this .kind = kind ;
7577 this .rootPath = rootPath ;
76- this .relativePath = relativePath ;
78+ this .relativePath = relativePath == null ? Path . of ( "" ) : relativePath ;
7779 }
7880
7981 public Kind getKind () {
Original file line number Diff line number Diff line change @@ -90,12 +90,9 @@ protected boolean startIfFirstTime() throws IOException {
9090 }
9191
9292 protected WatchEvent translate (java .nio .file .WatchEvent <?> jdkEvent ) {
93- var jdkKind = jdkEvent .kind ();
94- var context = jdkKind == StandardWatchEventKinds .OVERFLOW ? null : jdkEvent .context ();
95-
96- var kind = translate (jdkKind );
93+ var kind = translate (jdkEvent .kind ());
9794 var rootPath = path ;
98- var relativePath = context == null ? Path . of ( "" ) : (Path ) context ;
95+ var relativePath = kind == WatchEvent . Kind . OVERFLOW ? null : (@ Nullable Path ) jdkEvent . context () ;
9996
10097 var event = new WatchEvent (kind , rootPath , relativePath );
10198 logger .trace ("Translated: {} to {}" , jdkEvent , event );
You can’t perform that action at this time.
0 commit comments