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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 58fbfb3ba0 Use nanoseconds rather than milliseconds internally. Aligns 
with 10.0.x+
58fbfb3ba0 is described below

commit 58fbfb3ba096d75093aacf8c5d52be514d280f62
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 22 21:17:29 2025 +0100

    Use nanoseconds rather than milliseconds internally. Aligns with 10.0.x+
---
 java/org/apache/coyote/Request.java | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index 2de1201b87..639b326ba4 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
 import java.time.Instant;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.servlet.ReadListener;
@@ -149,7 +150,7 @@ public final class Request {
 
     private long bytesRead = 0;
     // Time of the request - useful to avoid repeated calls to 
System.currentTime
-    private long startTime = -1;
+    private long startTimeNanos = -1;
     private Instant startInstant = null;
     private long threadId = 0;
     private int available = 0;
@@ -692,7 +693,11 @@ public final class Request {
     }
 
     public long getStartTime() {
-        return startTime;
+        return System.currentTimeMillis() - 
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTimeNanos);
+    }
+
+    public long getStartTimeNanos() {
+        return startTimeNanos;
     }
 
     /**
@@ -702,12 +707,12 @@ public final class Request {
      */
     @Deprecated
     public void setStartTime(long startTime) {
-        this.startTime = startTime;
+        startTimeNanos = System.nanoTime() + 
TimeUnit.MILLISECONDS.toNanos(startTime - System.currentTimeMillis());
         startInstant = Instant.now();
     }
 
     public void markStartTime() {
-        startTime = System.currentTimeMillis();
+        startTimeNanos = System.nanoTime();
         startInstant = Instant.now();
     }
 
@@ -813,7 +818,7 @@ public final class Request {
         }
         allDataReadEventSent.set(false);
 
-        startTime = -1;
+        startTimeNanos = -1;
         startInstant = null;
         threadId = 0;
 


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

Reply via email to