diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index fbcf05857b422..fa19a952108aa 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -642,7 +642,10 @@ public void close() throws IOException { * @throws Exception */ @Override - public void reload(Settings settings) throws Exception { + public void reload(Settings settings) { + if (enabled == false || transportClient) { + return; + } for (NotificationService service : reloadableServices) { service.reload(settings); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java index 87a6321c15b45..a23830fd99f4f 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java @@ -124,9 +124,9 @@ public synchronized void reload(Settings settings) { } } - public void testReload() throws Exception { + public void testReload() { Settings settings = Settings.builder() - .put("xpack.watcher.enabled", false) + .put("xpack.watcher.enabled", true) .put("path.home", createTempDir()) .build(); NotificationService mockService = mock(NotificationService.class); @@ -138,4 +138,17 @@ public void testReload() throws Exception { watcher.reload(settings); verify(mockService, times(1)).reload(settings); } + + public void testReloadDisabled() { + Settings settings = Settings.builder() + .put("xpack.watcher.enabled", false) + .put("path.home", createTempDir()) + .build(); + NotificationService mockService = mock(NotificationService.class); + Watcher watcher = new Watcher(settings); + + verify(mockService, times(0)).reload(settings); + watcher.reload(settings); + verify(mockService, times(0)).reload(settings); + } }