From 770186f6cfd1a843f6cfca3df791093459b47f4b Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 19 Jul 2016 16:43:55 -0400 Subject: [PATCH] Catch the right rejected execution exception ThreadPool#schedule can throw a rejected execution exception. Yet, the rejected execution exception that it throws comes from the EsAbortPolicy which throws an EsRejectedExecutionException. This exception does not inherit from RejectedExecutionException so instead we must catch the former instead of the latter. --- .../main/java/org/elasticsearch/threadpool/ThreadPool.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index a2fea47dc4b..1de2f859b84 100644 --- a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.util.concurrent.EsAbortPolicy; import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler; @@ -50,7 +51,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; -import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -327,7 +327,7 @@ public class ThreadPool extends AbstractComponent implements Closeable { * @return a ScheduledFuture who's get will return when the task is has been added to its target thread pool and throw an exception if * the task is canceled before it was added to its target thread pool. Once the task has been added to its target thread pool * the ScheduledFuture will cannot interact with it. - * @throws java.util.concurrent.RejectedExecutionException {@inheritDoc} + * @throws org.elasticsearch.common.util.concurrent.EsRejectedExecutionException */ public ScheduledFuture schedule(TimeValue delay, String executor, Runnable command) { if (!Names.SAME.equals(executor)) { @@ -796,7 +796,7 @@ public class ThreadPool extends AbstractComponent implements Closeable { if (run) { try { threadPool.schedule(interval, executor, this); - } catch (final RejectedExecutionException e) { + } catch (final EsRejectedExecutionException e) { onRejection(e); } }