From ec9a4ecdc1eb52e75ba6d2f1baae6fa9e53a2ae7 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 7 Sep 2017 15:37:49 +0200 Subject: [PATCH] Fixed #1796 - ReservedThreadExecutor defaulting to capacity=1 only. Using getMaxThreads() instead of getThreads(). --- .../jetty/util/thread/ReservedThreadExecutor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java index 0d62fac9954..5010a631854 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java @@ -57,18 +57,18 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements Executo public ReservedThreadExecutor(Executor executor,int capacity) { _executor = executor; - + if (capacity < 0) { - if (executor instanceof ThreadPool) + int cpus = Runtime.getRuntime().availableProcessors(); + if (executor instanceof ThreadPool.SizedThreadPool) { - int threads = ((ThreadPool)executor).getThreads(); - int cpus = Runtime.getRuntime().availableProcessors(); - capacity = Math.max(1,Math.min(cpus,threads/8)); + int threads = ((ThreadPool.SizedThreadPool)executor).getMaxThreads(); + capacity = Math.max(1, Math.min(cpus, threads / 8)); } else { - capacity = Runtime.getRuntime().availableProcessors(); + capacity = cpus; } }