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

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

commit 98cf3c3dea16fade7bf8cae674e6c06377b78492
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Dec 1 19:10:49 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 3e00102b2f..771ca74131 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -1014,6 +1014,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);
@@ -1030,6 +1031,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