diff --git a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java index cf7ef56d296..9a936010758 100644 --- a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java @@ -109,7 +109,7 @@ public class ExecutionService extends AbstractComponent { this.indexDefaultTimeout = settings.getAsTime("xpack.watcher.internal.ops.index.default_timeout", TimeValue.timeValueSeconds(30)); } - public void start() throws Exception { + public synchronized void start() throws Exception { if (started.get()) { return; } @@ -133,7 +133,7 @@ public class ExecutionService extends AbstractComponent { return triggeredWatchStore.validate(state) && HistoryStore.validate(state); } - public void stop() { + public synchronized void stop() { if (started.compareAndSet(true, false)) { logger.debug("stopping execution service"); // We could also rely on the shutdown in #updateSettings call, but @@ -541,7 +541,7 @@ public class ExecutionService extends AbstractComponent { * This clears out the current executions and sets new empty current executions * This is needed, because when this method is called, watcher keeps running, so sealing executions would be a bad idea */ - public void clearExecutions() { + public synchronized void clearExecutions() { currentExecutions.sealAndAwaitEmpty(maxStopTimeout); currentExecutions = new CurrentExecutions(); }