Skip to content

Commit 770186f

Browse files
committed
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.
1 parent 720b53b commit 770186f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
3434
import org.elasticsearch.common.util.concurrent.EsAbortPolicy;
3535
import org.elasticsearch.common.util.concurrent.EsExecutors;
36+
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
3637
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
3738
import org.elasticsearch.common.util.concurrent.ThreadContext;
3839
import org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler;
@@ -50,7 +51,6 @@
5051
import java.util.Map;
5152
import java.util.concurrent.Executor;
5253
import java.util.concurrent.ExecutorService;
53-
import java.util.concurrent.RejectedExecutionException;
5454
import java.util.concurrent.RejectedExecutionHandler;
5555
import java.util.concurrent.ScheduledExecutorService;
5656
import java.util.concurrent.ScheduledFuture;
@@ -327,7 +327,7 @@ public Cancellable scheduleWithFixedDelay(Runnable command, TimeValue interval,
327327
* @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
328328
* the task is canceled before it was added to its target thread pool. Once the task has been added to its target thread pool
329329
* the ScheduledFuture will cannot interact with it.
330-
* @throws java.util.concurrent.RejectedExecutionException {@inheritDoc}
330+
* @throws org.elasticsearch.common.util.concurrent.EsRejectedExecutionException
331331
*/
332332
public ScheduledFuture<?> schedule(TimeValue delay, String executor, Runnable command) {
333333
if (!Names.SAME.equals(executor)) {
@@ -796,7 +796,7 @@ public void onAfter() {
796796
if (run) {
797797
try {
798798
threadPool.schedule(interval, executor, this);
799-
} catch (final RejectedExecutionException e) {
799+
} catch (final EsRejectedExecutionException e) {
800800
onRejection(e);
801801
}
802802
}

0 commit comments

Comments
 (0)