Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4D1C1888E for ; Fri, 26 Aug 2011 16:30:08 +0000 (UTC) Received: (qmail 95491 invoked by uid 500); 26 Aug 2011 16:30:07 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 95262 invoked by uid 500); 26 Aug 2011 16:30:06 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 95252 invoked by uid 99); 26 Aug 2011 16:30:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 16:30:05 +0000 X-ASF-Spam-Status: No, hits=-1.6 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [85.158.137.83] (HELO mail140.messagelabs.com) (85.158.137.83) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 16:29:57 +0000 X-Env-Sender: mick.sear@succeed.co.uk X-Msg-Ref: server-2.tower-140.messagelabs.com!1314376176!37087367!1 X-Originating-IP: [217.28.130.38] X-StarScan-Version: 6.3.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23673 invoked from network); 26 Aug 2011 16:29:36 -0000 Received: from hostedexchange.hostedservice.com (HELO outlook.hostedservice2.net) (217.28.130.38) by server-2.tower-140.messagelabs.com with RC4-SHA encrypted SMTP; 26 Aug 2011 16:29:36 -0000 Received: from THHS2E12BE2X.hostedservice2.net ([fe80:0000:0000:0000:e841:4ed5:117.193.90.34]) by thhs2e12ht03.hostedservice2.net ([192.168.16.113]) with mapi; Fri, 26 Aug 2011 17:29:35 +0100 From: Mick Sear To: Tomcat Developers List Date: Fri, 26 Aug 2011 17:29:34 +0100 Subject: Re: Possible bug in Tomcat Date header handling Thread-Topic: Possible bug in Tomcat Date header handling Thread-Index: AcxkDVddOlPRyGAGQ0KPU3MVyDR+hg== Message-ID: In-Reply-To: <4E57C567.1050108@christopherschultz.net> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.12.0.110505 acceptlanguage: en-US, en-GB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org 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 =3D System.currentTimeMillis(); if ((now - currentDateGenerated) > 1000) { synchronized (format) { if ((now - currentDateGenerated) > 1000) { currentDate =3D format.format(new Date(now)); currentDateGenerated =3D 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=20 On 26/08/2011 17:10, "Christopher Schultz" 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