fixed forbidden usage of Guava's MoreExecutors in Watcher

Original commit: elastic/x-pack-elasticsearch@5b977f9ff3
This commit is contained in:
Martijn van Groningen 2015-09-11 23:17:06 +02:00
parent 55f77fd52d
commit 16ad2edc33
2 changed files with 4 additions and 2 deletions

View File

@ -152,7 +152,7 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C
private void putTemplate(final TemplateConfig config, boolean wait) { private void putTemplate(final TemplateConfig config, boolean wait) {
final Executor executor; final Executor executor;
if (wait) { if (wait) {
executor = MoreExecutors.directExecutor(); executor = Runnable::run;
} else { } else {
executor = threadPool.generic(); executor = threadPool.generic();
} }

View File

@ -18,6 +18,8 @@ import org.junit.Test;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import java.util.concurrent.Executor;
import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@ -32,7 +34,7 @@ public class WatcherLifeCycleServiceTests extends ESTestCase {
@Before @Before
public void prepareServices() { public void prepareServices() {
ThreadPool threadPool = mock(ThreadPool.class); ThreadPool threadPool = mock(ThreadPool.class);
when(threadPool.executor(anyString())).thenReturn(MoreExecutors.newDirectExecutorService()); when(threadPool.executor(anyString())).thenReturn(Runnable::run);
clusterService = mock(ClusterService.class); clusterService = mock(ClusterService.class);
Answer<Object> answer = new Answer<Object>() { Answer<Object> answer = new Answer<Object>() {
@Override @Override