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 f76ce0d5e5 Refactor to remove use of ThreadLocal f76ce0d5e5 is described below commit f76ce0d5e50c7c9c25de5ed2fca2532e424b9804 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Feb 24 12:23:22 2023 +0000 Refactor to remove use of ThreadLocal ThreadLocal.get() calls Thread.currentThread() so caching the thread (or its attributes) in a ThreadLocal doesn't offer any performance benefits. --- java/org/apache/catalina/connector/CoyoteAdapter.java | 13 ------------- java/org/apache/coyote/Request.java | 4 +++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java b/java/org/apache/catalina/connector/CoyoteAdapter.java index 1d026eb35c..c674626bc7 100644 --- a/java/org/apache/catalina/connector/CoyoteAdapter.java +++ b/java/org/apache/catalina/connector/CoyoteAdapter.java @@ -73,23 +73,12 @@ public class CoyoteAdapter implements Adapter { public static final int ADAPTER_NOTES = 1; - protected static final boolean ALLOW_BACKSLASH = Boolean .parseBoolean(System.getProperty("org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH", "false")); - private static final ThreadLocal<String> THREAD_NAME = new ThreadLocal<String>() { - - @Override - protected String initialValue() { - return Thread.currentThread().getName(); - } - - }; - // ----------------------------------------------------------- Constructors - /** * Construct a new CoyoteProcessor associated with the specified connector. * @@ -134,7 +123,6 @@ public class CoyoteAdapter implements Adapter { boolean success = true; AsyncContextImpl asyncConImpl = request.getAsyncContextInternal(); - req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get()); req.setRequestThread(); try { @@ -342,7 +330,6 @@ public class CoyoteAdapter implements Adapter { boolean async = false; boolean postParseSuccess = false; - req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get()); req.setRequestThread(); try { diff --git a/java/org/apache/coyote/Request.java b/java/org/apache/coyote/Request.java index 45f5b66fe5..838dd34d57 100644 --- a/java/org/apache/coyote/Request.java +++ b/java/org/apache/coyote/Request.java @@ -700,7 +700,9 @@ public final class Request { } public void setRequestThread() { - threadId = Thread.currentThread().getId(); + Thread t = Thread.currentThread(); + threadId = t.getId(); + getRequestProcessor().setWorkerThreadName(t.getName()); } public boolean isRequestThread() { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org