From bad2d7ecce8ece2a9d11a9efdfaf47fc72bf8e49 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 4 Apr 2025 17:52:37 +1100 Subject: [PATCH 1/2] FileWatchingService shoudld not throw for missing file Missing file is a valid state for FileWatchingService so that the exception should be suppressed. --- .../common/file/AbstractFileWatchingService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 b731c210f37d5..c9993f12b63b9 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 final boolean watching() { } 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 From c55b82565bc43367f806b1b2cb6ffe8575a5824a Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 4 Apr 2025 17:56:31 +1100 Subject: [PATCH 2/2] Update docs/changelog/126264.yaml --- docs/changelog/126264.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/126264.yaml diff --git a/docs/changelog/126264.yaml b/docs/changelog/126264.yaml new file mode 100644 index 0000000000000..e2c4c6e4a8695 --- /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: []