|
@@ -50,6 +50,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.Executor;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
+import java.util.concurrent.RejectedExecutionException;
|
|
|
import java.util.concurrent.RejectedExecutionHandler;
|
|
import java.util.concurrent.RejectedExecutionHandler;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
import java.util.concurrent.ScheduledFuture;
|
|
@@ -326,6 +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
|
|
* @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 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.
|
|
* the ScheduledFuture will cannot interact with it.
|
|
|
|
|
+ * @throws java.util.concurrent.RejectedExecutionException {@inheritDoc}
|
|
|
*/
|
|
*/
|
|
|
public ScheduledFuture<?> schedule(TimeValue delay, String executor, Runnable command) {
|
|
public ScheduledFuture<?> schedule(TimeValue delay, String executor, Runnable command) {
|
|
|
if (!Names.SAME.equals(executor)) {
|
|
if (!Names.SAME.equals(executor)) {
|
|
@@ -792,7 +794,11 @@ public class ThreadPool extends AbstractComponent implements Closeable {
|
|
|
public void onAfter() {
|
|
public void onAfter() {
|
|
|
// if this has not been cancelled reschedule it to run again
|
|
// if this has not been cancelled reschedule it to run again
|
|
|
if (run) {
|
|
if (run) {
|
|
|
- threadPool.schedule(interval, executor, this);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ threadPool.schedule(interval, executor, this);
|
|
|
|
|
+ } catch (final RejectedExecutionException e) {
|
|
|
|
|
+ onRejection(e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|