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 203f0a07ee Refactor recording of request start time
203f0a07ee is described below
commit 203f0a07eea0ffc93a74ea8b83b31acca10f6133
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 df51a4ee87..a341735d19 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -1045,7 +1045,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 302589494f..2252e126e0 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -754,10 +754,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 0a8728a14b..53fb933336 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -380,7 +380,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 977036b093..dc1d30ac85 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -355,7 +355,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 3b811179b3..61966dea0f 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -161,7 +161,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]