This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 55ca737323725d5e9e9f7cf696ec70d2687c704a
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Dec 1 19:11:01 2026 +0000

    Read the action hook once in the request getters that use it
    
    getProtocolRequestId() and getServletConnection() read the volatile hook 
field
    twice. The field is cleared when the request is recycled, which can happen 
on
    another thread, so the second read could return null. Use a local copy as
    Request.action() already does.
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 java/org/apache/coyote/Request.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index bed70f15a2..693cfef94e 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -1076,6 +1076,7 @@ public final class Request {
      * @return the protocol request ID
      */
     public String getProtocolRequestId() {
+        ActionHook hook = this.hook;
         if (hook != null) {
             AtomicReference<String> ref = new AtomicReference<>();
             hook.action(ActionCode.PROTOCOL_REQUEST_ID, ref);
@@ -1092,6 +1093,7 @@ public final class Request {
      * @return the servlet connection
      */
     public ServletConnection getServletConnection() {
+        ActionHook hook = this.hook;
         if (hook != null) {
             AtomicReference<ServletConnection> ref = new AtomicReference<>();
             hook.action(ActionCode.SERVLET_CONNECTION, ref);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to