Skip to content

Commit dcf42b8

Browse files
authored
Merge pull request #19638 from rjernst/filewatcher_interface
Change file changes listener for resource watcher to an interface
2 parents 56ee492 + 95499c4 commit dcf42b8

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

core/src/main/java/org/elasticsearch/script/ScriptService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ public void onRemoval(RemovalNotification<CacheKey, CompiledScript> notification
487487
}
488488
}
489489

490-
private class ScriptChangesListener extends FileChangesListener {
490+
private class ScriptChangesListener implements FileChangesListener {
491491

492492
private Tuple<String, String> getScriptNameExt(Path file) {
493493
Path scriptPath = scriptsDirectory.relativize(file);

core/src/main/java/org/elasticsearch/watcher/FileChangesListener.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,39 @@
2323
/**
2424
* Callback interface that file changes File Watcher is using to notify listeners about changes.
2525
*/
26-
public class FileChangesListener {
26+
public interface FileChangesListener {
2727
/**
2828
* Called for every file found in the watched directory during initialization
2929
*/
30-
public void onFileInit(Path file) {
31-
32-
}
30+
default void onFileInit(Path file) {}
3331

3432
/**
3533
* Called for every subdirectory found in the watched directory during initialization
3634
*/
37-
public void onDirectoryInit(Path file) {
38-
39-
}
35+
default void onDirectoryInit(Path file) {}
4036

4137
/**
4238
* Called for every new file found in the watched directory
4339
*/
44-
public void onFileCreated(Path file) {
45-
46-
}
40+
default void onFileCreated(Path file) {}
4741

4842
/**
4943
* Called for every file that disappeared in the watched directory
5044
*/
51-
public void onFileDeleted(Path file) {
52-
53-
}
45+
default void onFileDeleted(Path file) {}
5446

5547
/**
5648
* Called for every file that was changed in the watched directory
5749
*/
58-
public void onFileChanged(Path file) {
59-
60-
}
50+
default void onFileChanged(Path file) {}
6151

6252
/**
6353
* Called for every new subdirectory found in the watched directory
6454
*/
65-
public void onDirectoryCreated(Path file) {
66-
67-
}
55+
default void onDirectoryCreated(Path file) {}
6856

6957
/**
7058
* Called for every file that disappeared in the watched directory
7159
*/
72-
public void onDirectoryDeleted(Path file) {
73-
74-
}
60+
default void onDirectoryDeleted(Path file) {}
7561
}

core/src/test/java/org/elasticsearch/watcher/FileWatcherTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
@LuceneTestCase.SuppressFileSystems("ExtrasFS")
3939
public class FileWatcherTests extends ESTestCase {
40-
private class RecordingChangeListener extends FileChangesListener {
40+
private class RecordingChangeListener implements FileChangesListener {
4141
private Path rootDir;
4242

4343
private RecordingChangeListener(Path rootDir) {

0 commit comments

Comments
 (0)