This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new d28bb22 Correct a regression in the fix for BZ 65454 d28bb22 is described below commit d28bb22ca076fceb275c748b0d511ed9bf12e8c2 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Feb 2 19:34:39 2022 +0000 Correct a regression in the fix for BZ 65454 Additional updates for new package for ThreadPoolExecutor https://bz.apache.org/bugzilla/show_bug.cgi?id=65454 --- .../catalina/loader/WebappClassLoaderBase.java | 14 ++++++++++---- .../org/apache/tomcat/util/net/AbstractEndpoint.java | 20 ++++++++++++-------- webapps/docs/changelog.xml | 5 +++++ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java b/java/org/apache/catalina/loader/WebappClassLoaderBase.java index 6a1c618..e6f70a8 100644 --- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java +++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java @@ -54,7 +54,6 @@ import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ThreadPoolExecutor; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; import java.util.jar.Manifest; @@ -77,6 +76,7 @@ import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.compat.JreCompat; import org.apache.tomcat.util.res.StringManager; import org.apache.tomcat.util.security.PermissionCheck; +import org.apache.tomcat.util.threads.ThreadPoolExecutor; /** * Specialized web application class loader. @@ -1839,16 +1839,22 @@ public abstract class WebappClassLoaderBase extends URLClassLoader } // "java.util.concurrent" code is in public domain, - // so all implementations are similar + // so all implementations are similar including our + // internal fork. if (target != null && target.getClass().getCanonicalName() != null && - target.getClass().getCanonicalName().equals( - "java.util.concurrent.ThreadPoolExecutor.Worker")) { + (target.getClass().getCanonicalName().equals( + "org.apache.tomcat.util.threads.ThreadPoolExecutor.Worker") || + target.getClass().getCanonicalName().equals( + "java.util.concurrent.ThreadPoolExecutor.Worker"))) { Field executorField = target.getClass().getDeclaredField("this$0"); executorField.setAccessible(true); Object executor = executorField.get(target); if (executor instanceof ThreadPoolExecutor) { ((ThreadPoolExecutor) executor).shutdownNow(); usingExecutor = true; + } else if (executor instanceof java.util.concurrent.ThreadPoolExecutor) { + ((java.util.concurrent.ThreadPoolExecutor) executor).shutdownNow(); + usingExecutor = true; } } } catch (NoSuchFieldException | IllegalAccessException | RuntimeException e) { diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java index 072e5b6..73cfbfb 100644 --- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java +++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java @@ -688,12 +688,12 @@ public abstract class AbstractEndpoint<S> { public void setMinSpareThreads(int minSpareThreads) { this.minSpareThreads = minSpareThreads; Executor executor = this.executor; - if (internalExecutor && executor instanceof java.util.concurrent.ThreadPoolExecutor) { + if (internalExecutor && executor instanceof ThreadPoolExecutor) { // The internal executor should always be an instance of - // j.u.c.ThreadPoolExecutor but it may be null if the endpoint is - // not running. + // org.apache.tomcat.util.threads.ThreadPoolExecutor but it may be + // null if the endpoint is not running. // This check also avoids various threading issues. - ((java.util.concurrent.ThreadPoolExecutor) executor).setCorePoolSize(minSpareThreads); + ((ThreadPoolExecutor) executor).setCorePoolSize(minSpareThreads); } } public int getMinSpareThreads() { @@ -715,12 +715,12 @@ public abstract class AbstractEndpoint<S> { public void setMaxThreads(int maxThreads) { this.maxThreads = maxThreads; Executor executor = this.executor; - if (internalExecutor && executor instanceof java.util.concurrent.ThreadPoolExecutor) { + if (internalExecutor && executor instanceof ThreadPoolExecutor) { // The internal executor should always be an instance of - // j.u.c.ThreadPoolExecutor but it may be null if the endpoint is - // not running. + // org.apache.tomcat.util.threads.ThreadPoolExecutor but it may be + // null if the endpoint is not running. // This check also avoids various threading issues. - ((java.util.concurrent.ThreadPoolExecutor) executor).setMaximumPoolSize(maxThreads); + ((ThreadPoolExecutor) executor).setMaximumPoolSize(maxThreads); } } public int getMaxThreads() { @@ -903,6 +903,8 @@ public abstract class AbstractEndpoint<S> { if (executor != null) { if (executor instanceof ThreadPoolExecutor) { return ((ThreadPoolExecutor) executor).getPoolSize(); + } else if (executor instanceof java.util.concurrent.ThreadPoolExecutor) { + return ((java.util.concurrent.ThreadPoolExecutor) executor).getPoolSize(); } else if (executor instanceof ResizableExecutor) { return ((ResizableExecutor) executor).getPoolSize(); } else { @@ -923,6 +925,8 @@ public abstract class AbstractEndpoint<S> { if (executor != null) { if (executor instanceof ThreadPoolExecutor) { return ((ThreadPoolExecutor) executor).getActiveCount(); + } else if (executor instanceof java.util.concurrent.ThreadPoolExecutor) { + return ((java.util.concurrent.ThreadPoolExecutor) executor).getActiveCount(); } else if (executor instanceof ResizableExecutor) { return ((ResizableExecutor) executor).getActiveCount(); } else { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index aa731fd..b7777a2 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -122,6 +122,11 @@ <subsection name="Coyote"> <changelog> <fix> + Correct a regression in the fix for <bug>65454</bug> that meant that + <code>minSpareThreads</code> and <code>maxThreads</code> settings were + ignored when the Connector used an internal executor. (markt) + </fix> + <fix> <bug>65848</bug>: Revert the change that attempted to align the behaviour of client certificate authentication with NIO or NIO2 with OpenSSL for TLS between MacOS and Linux/Windows as the root cause was --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org