Skip to content

Commit

Permalink
Fix enabled status on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
hub-cap committed Jul 3, 2018
1 parent 7be7b49 commit b97f21b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}

0 comments on commit b97f21b

Please sign in to comment.