summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-10-07 12:55:58 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2021-10-07 12:55:58 +0200
commit2c50eed11652022bf31eab9002277e57e331de23 (patch)
tree1dbd3da083c099914df28a18e95b7952efea3a57 /container-core
parent03224ae1749a058c88ee926738195ae0d3204322 (diff)
If execution is rejected, fall back to doing it yourself.
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java2
-rw-r--r--container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java12
2 files changed, 11 insertions, 3 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java b/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java
index b27efcc13f0..8d07e7c3757 100644
--- a/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java
+++ b/container-core/src/main/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadpool.java
@@ -56,7 +56,7 @@ public class DefaultContainerThreadpool extends AbstractComponent implements Aut
threadPoolMetric);
// Prestart needed, if not all threads will be created by the fist N tasks and hence they might also
// get the dreaded thread locals initialized even if they will never run.
- // That counters what we we want to achieve with the Q that will prefer thread locality.
+ // That counters what we want to achieve with the Q that will prefer thread locality.
executor.prestartAllCoreThreads();
threadpool = new ExecutorServiceWrapper(
executor, threadPoolMetric, processTerminator, config.maxThreadExecutionTimeSeconds() * 1000L,
diff --git a/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java b/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java
index a92bf5ec9f7..0a112945682 100644
--- a/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java
+++ b/container-core/src/main/java/com/yahoo/processing/execution/AsyncExecution.java
@@ -100,13 +100,21 @@ public class AsyncExecution {
private static <T> Future<T> getFuture(final Callable<T> callable) {
FutureTask<T> future = new FutureTask<>(callable);
- executorMain.execute(future);
+ try {
+ executorMain.execute(future);
+ } catch (RejectedExecutionException e) {
+ future.run();
+ }
return future;
}
private FutureResponse getFutureResponse(Callable<Response> callable, Request request) {
FutureResponse future = new FutureResponse(callable, execution, request);
- executorMain.execute(future.delegate());
+ try {
+ executorMain.execute(future.delegate());
+ } catch (RejectedExecutionException e) {
+ future.delegate().run();
+ }
return future;
}