On 24/09/2025 03:05, Christopher Schultz wrote:
Mark,
On 9/22/25 3:46 PM, [email protected] wrote:
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new a13c5d3326 Record the instant the request processing starts.
a13c5d3326 is described below
commit a13c5d33265b7779dce46c4a3155399eaa8820c7
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 22 20:44:44 2025 +0100
Record the instant the request processing starts.
---
java/org/apache/coyote/Request.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/java/org/apache/coyote/Request.java b/java/org/apache/
coyote/Request.java
index 2252e126e0..573e524fad 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
+import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -163,6 +164,7 @@ public final class Request {
private long bytesRead = 0;
// Time of the request - useful to avoid repeated calls to
System.currentTime
private long startTimeNanos = -1;
+ private Instant startInstant = null;
private long threadId = 0;
private int available = 0;
@@ -764,10 +766,16 @@ public final class Request {
@Deprecated
public void setStartTimeNanos(long startTimeNanos) {
this.startTimeNanos = startTimeNanos;
+ startInstant = Instant.now();
}
As this point, you can change getStartTimeNanos to:
return startInstant.getEpochSecond() * 1_000_000_000L +
startInstant.getNano();
That trades computation for assignment, so it may not be worth it.
I'm not sure I can.
startInstant is based on a clock (which might changed e.g. by NTP)
whereas System.nanoTime() is absolute.
The idea is that request processing time remains robust against changes
in the system time whereas request start time might change.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]