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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 98df9a1201 Refactor recording of request start time
98df9a1201 is described below

commit 98df9a1201a810f6330487144d4216aa3514fc7b
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 22 16:55:02 2025 +0100

    Refactor recording of request start time
---
 java/org/apache/coyote/AbstractProcessor.java        |  2 +-
 java/org/apache/coyote/Request.java                  | 12 ++++++++++++
 java/org/apache/coyote/ajp/AjpProcessor.java         |  2 +-
 java/org/apache/coyote/http11/Http11InputBuffer.java |  2 +-
 java/org/apache/coyote/http2/Stream.java             |  2 +-
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index 9362f5932f..7a41c92f57 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -1075,7 +1075,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
         // information (e.g. client IP)
         setSocketWrapper(socketWrapper);
         // Set up the minimal request information
-        request.setStartTimeNanos(System.nanoTime());
+        request.markStartTime();
         // Set up the minimal response information
         response.setStatus(400);
         response.setError();
diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index 12c31a1bbb..378c943458 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -738,10 +738,22 @@ public final class Request {
         return startTimeNanos;
     }
 
+    /**
+     * Set the start time using the value provided by {@code 
System.nanoTime()}.
+     *
+     * @param startTimeNanos The value returned from {@code System.nanoTime()} 
at the point the requests started.
+     *
+     * @deprecated Unused. Will be removed in Tomcat 12 onwards. Use {@link 
#markStartTime()}.
+     */
+    @Deprecated
     public void setStartTimeNanos(long startTimeNanos) {
         this.startTimeNanos = startTimeNanos;
     }
 
+    public void markStartTime() {
+        startTimeNanos = System.nanoTime();
+    }
+
     public long getThreadId() {
         return threadId;
     }
diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index 7e9128957c..3164656346 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -378,7 +378,7 @@ public class AjpProcessor extends AbstractProcessor {
                     setErrorState(ErrorState.CLOSE_CONNECTION_NOW, null);
                     break;
                 }
-                request.setStartTimeNanos(System.nanoTime());
+                request.markStartTime();
             } 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 22b1af5f6b..e0fb9cefcc 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -366,7 +366,7 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
                 // just skipping blank lines)
                 if (parsingRequestLinePhase == 0) {
                     parsingRequestLinePhase = 1;
-                    request.setStartTimeNanos(System.nanoTime());
+                    request.markStartTime();
                 }
                 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 263df2f583..a39ebd1afe 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -165,7 +165,7 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
         this.coyoteResponse.setOutputBuffer(http2OutputBuffer);
         this.coyoteRequest.setResponse(coyoteResponse);
         this.coyoteRequest.protocol().setString("HTTP/2.0");
-        this.coyoteRequest.setStartTimeNanos(System.nanoTime());
+        this.coyoteRequest.markStartTime();
     }
 
 


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

Reply via email to