diff --git a/core/src/main/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutor.java b/core/src/main/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutor.java index 6d94fec17d7..fde8d828295 100644 --- a/core/src/main/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutor.java +++ b/core/src/main/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutor.java @@ -184,13 +184,14 @@ public class EsThreadPoolExecutor extends ThreadPoolExecutor { @Override protected void doRun() throws Exception { - boolean started = false; + boolean whileRunning = false; try (ThreadContext.StoredContext ingore = contextHolder.stashContext()){ ctx.restore(); - started = true; + whileRunning = true; in.doRun(); + whileRunning = false; } catch (IllegalStateException ex) { - if (started || isShutdown() == false) { + if (whileRunning || isShutdown() == false) { throw ex; } // if we hit an ISE here we have been shutting down @@ -219,13 +220,14 @@ public class EsThreadPoolExecutor extends ThreadPoolExecutor { @Override public void run() { - boolean started = false; + boolean whileRunning = false; try (ThreadContext.StoredContext ingore = contextHolder.stashContext()){ ctx.restore(); - started = true; + whileRunning = true; in.run(); + whileRunning = false; } catch (IllegalStateException ex) { - if (started || isShutdown() == false) { + if (whileRunning || isShutdown() == false) { throw ex; } // if we hit an ISE here we have been shutting down diff --git a/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java b/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java index 2fe11b5875c..06e20fd31f1 100644 --- a/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java +++ b/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java @@ -325,7 +325,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase { try { Settings nodeSettings = Settings.settingsBuilder() .put("threadpool." + threadPoolName + ".queue_size", 1000) - .put("name", "testCachedExecutorType").build(); + .put("name", "testShutdownNowInterrupts").build(); threadPool = new ThreadPool(nodeSettings); ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); threadPool.setClusterSettings(clusterSettings);