Skip to content

Commit b97f21b

Browse files
committed
Fix enabled status on reload
1 parent 7be7b49 commit b97f21b

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,10 @@ public void close() throws IOException {
642642
* @throws Exception
643643
*/
644644
@Override
645-
public void reload(Settings settings) throws Exception {
645+
public void reload(Settings settings) {
646+
if (enabled == false || transportClient) {
647+
return;
648+
}
646649
for (NotificationService service : reloadableServices) {
647650
service.reload(settings);
648651
}

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ public synchronized void reload(Settings settings) {
124124
}
125125
}
126126

127-
public void testReload() throws Exception {
127+
public void testReload() {
128128
Settings settings = Settings.builder()
129-
.put("xpack.watcher.enabled", false)
129+
.put("xpack.watcher.enabled", true)
130130
.put("path.home", createTempDir())
131131
.build();
132132
NotificationService mockService = mock(NotificationService.class);
@@ -138,4 +138,17 @@ public void testReload() throws Exception {
138138
watcher.reload(settings);
139139
verify(mockService, times(1)).reload(settings);
140140
}
141+
142+
public void testReloadDisabled() {
143+
Settings settings = Settings.builder()
144+
.put("xpack.watcher.enabled", false)
145+
.put("path.home", createTempDir())
146+
.build();
147+
NotificationService mockService = mock(NotificationService.class);
148+
Watcher watcher = new Watcher(settings);
149+
150+
verify(mockService, times(0)).reload(settings);
151+
watcher.reload(settings);
152+
verify(mockService, times(0)).reload(settings);
153+
}
141154
}

0 commit comments

Comments
 (0)