diff --git a/docs/changelog/126264.yaml b/docs/changelog/126264.yaml new file mode 100644 index 000000000000..e2c4c6e4a869 --- /dev/null +++ b/docs/changelog/126264.yaml @@ -0,0 +1,5 @@ +pr: 126264 +summary: '`FileWatchingService` shoudld not throw for missing file' +area: Infra/Settings +type: enhancement +issues: [] diff --git a/server/src/main/java/org/elasticsearch/common/file/AbstractFileWatchingService.java b/server/src/main/java/org/elasticsearch/common/file/AbstractFileWatchingService.java index b731c210f37d..c9993f12b63b 100644 --- a/server/src/main/java/org/elasticsearch/common/file/AbstractFileWatchingService.java +++ b/server/src/main/java/org/elasticsearch/common/file/AbstractFileWatchingService.java @@ -116,15 +116,13 @@ public abstract class AbstractFileWatchingService extends AbstractLifecycleCompo } private FileUpdateState readFileUpdateState(Path path) throws IOException { - BasicFileAttributes attr; try { - attr = filesReadAttributes(path, BasicFileAttributes.class); + BasicFileAttributes attr = filesReadAttributes(path, BasicFileAttributes.class); + return new FileUpdateState(attr.lastModifiedTime().toMillis(), path.toRealPath().toString(), attr.fileKey()); } catch (NoSuchFileException e) { // file doesn't exist anymore return null; } - - return new FileUpdateState(attr.lastModifiedTime().toMillis(), path.toRealPath().toString(), attr.fileKey()); } // platform independent way to tell if a file changed