Skip to content

Commit bad2d7e

Browse files
committed
FileWatchingService shoudld not throw for missing file
Missing file is a valid state for FileWatchingService so that the exception should be suppressed.
1 parent 70654a3 commit bad2d7e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

server/src/main/java/org/elasticsearch/common/file/AbstractFileWatchingService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,13 @@ public final boolean watching() {
116116
}
117117

118118
private FileUpdateState readFileUpdateState(Path path) throws IOException {
119-
BasicFileAttributes attr;
120119
try {
121-
attr = filesReadAttributes(path, BasicFileAttributes.class);
120+
BasicFileAttributes attr = filesReadAttributes(path, BasicFileAttributes.class);
121+
return new FileUpdateState(attr.lastModifiedTime().toMillis(), path.toRealPath().toString(), attr.fileKey());
122122
} catch (NoSuchFileException e) {
123123
// file doesn't exist anymore
124124
return null;
125125
}
126-
127-
return new FileUpdateState(attr.lastModifiedTime().toMillis(), path.toRealPath().toString(), attr.fileKey());
128126
}
129127

130128
// platform independent way to tell if a file changed

0 commit comments

Comments
 (0)