From 6c8d85cd2be2d21a9b6a0ddbe13bc412bdbbd7df Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 21 Mar 2017 11:22:48 -0400 Subject: [PATCH 1/2] Javadoc: ThreadPool doesn't reject while shutdown It caught me offguard yesterday that our executors won't always reject when the ThreadPool is shutdown. --- .../org/elasticsearch/threadpool/ThreadPool.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index b68037b8dc6f2..8261e3899e9a3 100644 --- a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -295,16 +295,24 @@ public ThreadPoolStats stats() { } /** - * Get the generic executor service. This executor service {@link Executor#execute(Runnable)} method will run the {@link Runnable} it - * is given in the {@link ThreadContext} of the thread that queues it. + * Get the generic {@link ExecutorService}. This executor service + * {@link Executor#execute(Runnable)} method will run the {@link Runnable} it is given in the + * {@link ThreadContext} of the thread that queues it. + *

+ * Warning: this {@linkplain ExecutorService} will not throw {@link RejectedExecutionException} + * if you submit a task while it shutdown. It will instead silently queue it and not run it. */ public ExecutorService generic() { return executor(Names.GENERIC); } /** - * Get the executor service with the given name. This executor service's {@link Executor#execute(Runnable)} method will run the - * {@link Runnable} it is given in the {@link ThreadContext} of the thread that queues it. + * Get the {@link ExecutorService} with the given name. This executor service's + * {@link Executor#execute(Runnable)} method will run the {@link Runnable} it is given in the + * {@link ThreadContext} of the thread that queues it. + *

+ * Warning: this {@linkplain ExecutorService} might not throw {@link RejectedExecutionException} + * if you submit a task while it shutdown. It will instead silently queue it and not run it. * * @param name the name of the executor service to obtain * @throws IllegalArgumentException if no executor service with the specified name exists From 13fa22bfbf7bf835f3e82fd102bc914507468d90 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 23 Mar 2017 09:48:56 -0400 Subject: [PATCH 2/2] Add missing import --- core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index 8261e3899e9a3..460fe9c7e1420 100644 --- a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -53,6 +53,7 @@ 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;