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
commit 9a9e15d5eff6ce93e2360bf8d39b03d083058760 Author: Chenjp <ch...@msn.com> AuthorDate: Fri Sep 13 09:30:29 2024 +0800 Update FastHttpDateFormat.java Follows markt-asf suggestion, change internal currentDateGenerated unit from ms to sec. --- java/org/apache/tomcat/util/http/FastHttpDateFormat.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java index df965a8e82..157f451507 100644 --- a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java +++ b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java @@ -71,9 +71,9 @@ public final class FastHttpDateFormat { } /** - * Instant on which the currentDate object was generated. + * Instant on which the currentDate object was generated. */ - private static volatile long currentDateGenerated = 0L; + private static volatile long currentDateGeneratedInSeconds = 0L; /** @@ -103,12 +103,11 @@ public final class FastHttpDateFormat { * @return the HTTP date */ public static String getCurrentDate() { - long now = System.currentTimeMillis(); - // Ignore millisecond part. - now -= now % 1000L; - if (now != currentDateGenerated) { - currentDate = FORMAT_RFC5322.format(new Date(now)); - currentDateGenerated = now; + // according rfc5322, date/time data is accurate to the second. + long nowInSeconds = System.currentTimeMillis() / 1000L; + if (nowInSeconds != currentDateGeneratedInSeconds) { + currentDate = FORMAT_RFC5322.format(new Date(nowInSeconds * 1000L)); + currentDateGeneratedInSeconds = nowInSeconds; } return currentDate; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org