This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 8e2ffdc Avoid incrementing request ID on multiple calls to recycle.
8e2ffdc is described below
commit 8e2ffdc8ca1ca4abfc862d5097d8e02e35fac289
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 27 22:07:00 2021 +0100
Avoid incrementing request ID on multiple calls to recycle.
---
java/org/apache/coyote/Request.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/coyote/Request.java
b/java/org/apache/coyote/Request.java
index d9d0732..08dc535 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -108,7 +108,7 @@ public final class Request {
private final MessageBytes queryMB = MessageBytes.newInstance();
private final MessageBytes protoMB = MessageBytes.newInstance();
- private String requestId =
Long.toString(requestIdGenerator.getAndIncrement());
+ private volatile String requestId =
Long.toString(requestIdGenerator.getAndIncrement());
// remote address/host
private final MessageBytes remoteAddrMB = MessageBytes.newInstance();
@@ -793,7 +793,13 @@ public final class Request {
available = 0;
sendfile = true;
- requestId = Long.toHexString(requestIdGenerator.getAndIncrement());
+ // There may be multiple calls to recycle but only the first should
+ // trigger a change in the request ID until a new request has been
+ // started. Use startTimeNanos to detect when a request has started so
a
+ // subsequent call to recycle() will trigger a change in the request
ID.
+ if (startTimeNanos != -1) {
+ requestId = Long.toHexString(requestIdGenerator.getAndIncrement());
+ }
serverCookies.recycle();
parameters.recycle();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]