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

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

commit 03772dada9e5ac20841865b89a04b409d478e764
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Dec 1 19:11:04 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 e40408eb34..7d778b2ffa 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -1041,6 +1041,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);
@@ -1057,6 +1058,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