From 01c5be1da313e9e8c12c6d680b879ca532c11167 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 6 Jan 2014 21:39:20 +0100 Subject: [PATCH] generic thread pool should always be cached when using generic thread pool, some elements in the code base rely on the fact that it will always be able to fork it --- src/main/java/org/elasticsearch/threadpool/ThreadPool.java | 3 +++ src/test/java/org/elasticsearch/test/TestCluster.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index fb9c200a953..c1b6a50a4a0 100644 --- a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -125,6 +125,9 @@ public class ThreadPool extends AbstractComponent { executors.put(executor.getKey(), build(executor.getKey(), groupSettings.get(executor.getKey()), executor.getValue())); } executors.put(Names.SAME, new ExecutorHolder(MoreExecutors.sameThreadExecutor(), new Info(Names.SAME, "same"))); + if (!executors.get(Names.GENERIC).info.getType().equals("cached")) { + throw new ElasticSearchIllegalArgumentException("generic thread pool must be of type cached"); + } this.executors = ImmutableMap.copyOf(executors); this.scheduler = new ScheduledThreadPoolExecutor(1, EsExecutors.daemonThreadFactory(settings, "scheduler"), new EsAbortPolicy()); this.scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); diff --git a/src/test/java/org/elasticsearch/test/TestCluster.java b/src/test/java/org/elasticsearch/test/TestCluster.java index a49e2ee2de0..922d65c2ffc 100644 --- a/src/test/java/org/elasticsearch/test/TestCluster.java +++ b/src/test/java/org/elasticsearch/test/TestCluster.java @@ -232,7 +232,7 @@ public final class TestCluster implements Iterable { } if (random.nextBoolean()) { // change threadpool types to make sure we don't have components that rely on the type of thread pools - for (String name : Arrays.asList(ThreadPool.Names.BULK, ThreadPool.Names.FLUSH, ThreadPool.Names.GENERIC, ThreadPool.Names.GET, + for (String name : Arrays.asList(ThreadPool.Names.BULK, ThreadPool.Names.FLUSH, ThreadPool.Names.GET, ThreadPool.Names.INDEX, ThreadPool.Names.MANAGEMENT, ThreadPool.Names.MERGE, ThreadPool.Names.OPTIMIZE, ThreadPool.Names.PERCOLATE, ThreadPool.Names.REFRESH, ThreadPool.Names.SEARCH, ThreadPool.Names.SNAPSHOT, ThreadPool.Names.SUGGEST, ThreadPool.Names.WARMER)) {