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

commit 7161acc4b84e16fb24479bf074e701f3e8b58e89
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 29 08:25:55 2025 +0100

    Revert "Refactor recording of request start time"
    
    This reverts commit 6909ac966bcafd21d1633ccde63428b8bf491a37.
---
 java/org/apache/coyote/AbstractProcessor.java        |  6 +++---
 java/org/apache/coyote/Request.java                  | 12 ------------
 java/org/apache/coyote/ajp/AjpProcessor.java         |  2 +-
 java/org/apache/coyote/http11/Http11InputBuffer.java |  7 ++++---
 java/org/apache/coyote/http2/Stream.java             |  4 +++-
 5 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index 6cfb24ec83..3b8164eb46 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -1083,9 +1083,9 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
         // Set the socket wrapper so the access log can read the socket related
         // information (e.g. client IP)
         setSocketWrapper(socketWrapper);
-        // Set up the minimal request information
-        request.markStartTime();
-        // Set up the minimal response information
+        // Setup the minimal request information
+        request.setStartTime(System.currentTimeMillis());
+        // Setup the minimal response information
         response.setStatus(400);
         response.setError();
         getAdapter().log(request, response, 0);
diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index 1808262e71..7ed5ef4cd8 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -693,22 +693,10 @@ public final class Request {
         return startTime;
     }
 
-    /**
-     * Set the start time using the value provided by {@code 
System.currentTimeMillis()}.
-     *
-     * @param startTime The value returned from {@code 
System.currentTimeMillis()} at the point the requests started.
-     *
-     * @deprecated Unused. Will be removed in Tomcat 12 onwards. Use {@link 
#markStartTime()}.
-     */
-    @Deprecated
     public void setStartTime(long startTime) {
         this.startTime = startTime;
     }
 
-    public void markStartTime() {
-        startTime = System.currentTimeMillis();
-    }
-
     public long getThreadId() {
         return threadId;
     }
diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index 7f5070f4c5..5c129a13b5 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -385,7 +385,7 @@ public class AjpProcessor extends AbstractProcessor {
                     setErrorState(ErrorState.CLOSE_CONNECTION_NOW, null);
                     break;
                 }
-                request.markStartTime();
+                request.setStartTime(System.currentTimeMillis());
             } catch (IOException ioe) {
                 setErrorState(ErrorState.CLOSE_CONNECTION_NOW, ioe);
                 break;
diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java 
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index e0fb9cefcc..9903301011 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -343,6 +343,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
                         wrapper.setReadTimeout(keepAliveTimeout);
                     }
                     if (!fill(false)) {
+                        // A read is pending, so no longer in initial state
+                        parsingRequestLinePhase = 1;
                         return false;
                     }
                     // At least one byte of the request has been received.
@@ -364,9 +366,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
                 }
                 // Set the start time once we start reading data (even if it is
                 // just skipping blank lines)
-                if (parsingRequestLinePhase == 0) {
-                    parsingRequestLinePhase = 1;
-                    request.markStartTime();
+                if (request.getStartTime() < 0) {
+                    request.setStartTime(System.currentTimeMillis());
                 }
                 chr = byteBuffer.get();
             } while (chr == Constants.CR || chr == Constants.LF);
diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 94322c6fc6..ce7d9e50cd 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -166,7 +166,9 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
         this.coyoteResponse.setOutputBuffer(http2OutputBuffer);
         this.coyoteRequest.setResponse(coyoteResponse);
         this.coyoteRequest.protocol().setString("HTTP/2.0");
-        this.coyoteRequest.markStartTime();
+        if (this.coyoteRequest.getStartTime() < 0) {
+            this.coyoteRequest.setStartTime(System.currentTimeMillis());
+        }
     }
 
 


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

Reply via email to