This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 9a9a10d  Allow http response date field set to older date
9a9a10d is described below

commit 9a9a10d874bfeb844eee1a987b47bf5701b766f1
Author: zhenguoli <zhengu...@yandex.com>
AuthorDate: Wed Jan 19 22:18:42 2022 +0800

    Allow http response date field set to older date
---
 java/org/apache/tomcat/util/http/FastHttpDateFormat.java | 3 ++-
 webapps/docs/changelog.xml                               | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java 
b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java
index a546ee6..73c578e 100644
--- a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java
+++ b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java
@@ -103,7 +103,8 @@ public final class FastHttpDateFormat {
      */
     public static final String getCurrentDate() {
         long now = System.currentTimeMillis();
-        if ((now - currentDateGenerated) > 1000) {
+        // Handle case where time moves backwards (e.g. system time corrected)
+        if (Math.abs(now - currentDateGenerated) > 1000) {
             currentDate = FORMAT_RFC5322.format(new Date(now));
             currentDateGenerated = now;
         }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 093ea78..e1a2526 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -147,6 +147,12 @@
         OpenSSL for TLS between MacOS and Linux/Windows as the root cause was
         traced to configuration differences. (markt)
       </fix>
+      <fix>
+        <pr>467</pr>: When system time moves backwards (e.g. after clock
+        correction), ensure that the cached formatted current date used for
+        HTTP headers tracks this change. Pull request provided by zhenguoli.
+        (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to