Issue #10333 - save the value of Request.getTimeStamp so it returns consistent value.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2023-10-04 09:42:37 +11:00
parent 27865d29b4
commit a56faad195
1 changed files with 8 additions and 1 deletions

View File

@ -121,6 +121,7 @@ public interface Request extends Attributes, Content.Source
{
String CACHE_ATTRIBUTE = Request.class.getCanonicalName() + ".CookieCache";
String COOKIE_ATTRIBUTE = Request.class.getCanonicalName() + ".Cookies";
String TIMESTAMP_ATTRIBUTE = Request.class.getCanonicalName() + ".TimeStamp";
List<Locale> DEFAULT_LOCALES = List.of(Locale.getDefault());
/**
@ -223,7 +224,13 @@ public interface Request extends Attributes, Content.Source
*/
static long getTimeStamp(Request request)
{
return System.currentTimeMillis() - NanoTime.millisSince(request.getHeadersNanoTime());
Long timeStampAttribute = (Long)request.getAttribute(TIMESTAMP_ATTRIBUTE);
if (timeStampAttribute != null)
return timeStampAttribute;
long timeStamp = System.currentTimeMillis() - NanoTime.millisSince(request.getHeadersNanoTime());
request.setAttribute(TIMESTAMP_ATTRIBUTE, timeStamp);
return timeStamp;
}
/**