From 16ad2edc3378295f4b056093acc9866dc4f0e7d1 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 11 Sep 2015 23:17:06 +0200 Subject: [PATCH] fixed forbidden usage of Guava's MoreExecutors in Watcher Original commit: elastic/x-pack-elasticsearch@5b977f9ff37d79ee0316fb7fdf4c5775af9c7725 --- .../watcher/support/WatcherIndexTemplateRegistry.java | 2 +- .../elasticsearch/watcher/WatcherLifeCycleServiceTests.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/watcher/src/main/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistry.java b/watcher/src/main/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistry.java index 0afc63f2cbe..fc4612b352a 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistry.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistry.java @@ -152,7 +152,7 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C private void putTemplate(final TemplateConfig config, boolean wait) { final Executor executor; if (wait) { - executor = MoreExecutors.directExecutor(); + executor = Runnable::run; } else { executor = threadPool.generic(); } diff --git a/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java b/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java index ed66e2a49ed..ec44247fb26 100644 --- a/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java +++ b/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java @@ -18,6 +18,8 @@ import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import java.util.concurrent.Executor; + import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; @@ -32,7 +34,7 @@ public class WatcherLifeCycleServiceTests extends ESTestCase { @Before public void prepareServices() { ThreadPool threadPool = mock(ThreadPool.class); - when(threadPool.executor(anyString())).thenReturn(MoreExecutors.newDirectExecutorService()); + when(threadPool.executor(anyString())).thenReturn(Runnable::run); clusterService = mock(ClusterService.class); Answer answer = new Answer() { @Override