mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-19 04:45:07 -04:00
FileWatchingService should not throw for missing file (#126264)
Missing file is a valid state for FileWatchingService so that the exception should be suppressed.
This commit is contained in:
parent
991e80d56e
commit
997a7b8fab
2 changed files with 7 additions and 4 deletions
5
docs/changelog/126264.yaml
Normal file
5
docs/changelog/126264.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
pr: 126264
|
||||||
|
summary: '`FileWatchingService` shoudld not throw for missing file'
|
||||||
|
area: Infra/Settings
|
||||||
|
type: enhancement
|
||||||
|
issues: []
|
|
@ -116,15 +116,13 @@ public abstract class AbstractFileWatchingService extends AbstractLifecycleCompo
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileUpdateState readFileUpdateState(Path path) throws IOException {
|
private FileUpdateState readFileUpdateState(Path path) throws IOException {
|
||||||
BasicFileAttributes attr;
|
|
||||||
try {
|
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) {
|
} catch (NoSuchFileException e) {
|
||||||
// file doesn't exist anymore
|
// file doesn't exist anymore
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FileUpdateState(attr.lastModifiedTime().toMillis(), path.toRealPath().toString(), attr.fileKey());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// platform independent way to tell if a file changed
|
// platform independent way to tell if a file changed
|
||||||
|
|
Loading…
Add table
Reference in a new issue