tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mick Sear <mick.s...@succeed.co.uk>
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?

Thanks,
Mick 



On 26/08/2011 17:10, "Christopher Schultz" <chris@christopherschultz.net>
wrote:

>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.
>
>+1
>
>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.
>
>-chris
>


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


Mime
View raw message