You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/02/02 19:37:20 UTC
[tomcat] branch 9.0.x updated: Correct a regression in the fix for BZ 65454
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new baa7765 Correct a regression in the fix for BZ 65454
baa7765 is described below
commit baa776584190e1d937b41153e7464fcec849986a
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 a806a35..548fabe 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.
@@ -1833,16 +1833,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 d5d0e25..98f07e7 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -723,12 +723,12 @@ public abstract class AbstractEndpoint<S,U> {
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() {
@@ -750,12 +750,12 @@ public abstract class AbstractEndpoint<S,U> {
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() {
@@ -943,6 +943,8 @@ public abstract class AbstractEndpoint<S,U> {
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 {
@@ -963,6 +965,8 @@ public abstract class AbstractEndpoint<S,U> {
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 a26fe1f..42f8764 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org