tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mick Sear <>
Subject Re: Possible bug in Tomcat Date header handling
Date Fri, 26 Aug 2011 16:29:34 GMT
I agree that a poorly configured system clock is not something Tomcat is
responsible for, per se.  However, there is a problem in the following
code as I see it, which can be easily fixed by checking also for a
negative number.  This is a small fix that caters for people being dumb:

* Get the current date in HTTP format.
public static final String getCurrentDate() {

   long now = System.currentTimeMillis();
   if ((now - currentDateGenerated) > 1000) {
      synchronized (format) {
         if ((now - currentDateGenerated) > 1000) {
            currentDate = format.format(new Date(now));
            currentDateGenerated = now;
   return currentDate;


I also think that looking at this code, if clocks go back at, say, 2am in
a given time zone, Tomcat will report 2am in an HTTP header continually
for 1 hour.

Am I wrong?


On 26/08/2011 17:10, "Christopher Schultz" <>

>Mark and Mick,
>On 8/26/2011 11:45 AM, Mark Thomas wrote:
>> The fix is to address the root cause which appears to be a poorly
>> configured system clock. I am loath to add a work-around at any point in
>> the Tomcat source code to handle time apparently going backwards rather
>> than forwards.
>This is not something that should happen on a stable server. DST
>adjustments will not cause Tomcat to report the same Date header for an
>hour (or whatever it is in your time zone) after DST rolls back.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message