From: fhanik Date: Fri, 30 Jan 2009 22:09:15 +0000 (+0000) Subject: even not used anywhere in our code, make it thread safe X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=548141b897a00c67fee82cabecafc50fa3929c1d;p=tomcat7.0 even not used anywhere in our code, make it thread safe git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@739427 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/util/DateTool.java b/java/org/apache/catalina/util/DateTool.java index ad2d1f3dd..2d73225e0 100644 --- a/java/org/apache/catalina/util/DateTool.java +++ b/java/org/apache/catalina/util/DateTool.java @@ -30,6 +30,7 @@ import java.util.TimeZone; * @author Jason Hunter [jch@eng.sun.com] * @author James Todd [gonzo@eng.sun.com] * @author Costin Manolache + * @author fhanik */ public class DateTool { @@ -71,26 +72,45 @@ public class DateTool { /** * DateFormat to be used to format dates */ - public final static DateFormat rfc1123Format = - new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); + public final static ThreadLocal rfc1123Format = new ThreadLocal() { + @Override + public DateFormat initialValue() { + DateFormat result = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); + result.setTimeZone(GMT_ZONE); + return result; + } + }; /** * DateFormat to be used to format old netscape cookies */ - public final static DateFormat oldCookieFormat = - new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US); - - public final static DateFormat rfc1036Format = - new SimpleDateFormat(rfc1036Pattern, LOCALE_US); - - public final static DateFormat asctimeFormat = - new SimpleDateFormat(asctimePattern, LOCALE_US); - - static { - rfc1123Format.setTimeZone(GMT_ZONE); - oldCookieFormat.setTimeZone(GMT_ZONE); - rfc1036Format.setTimeZone(GMT_ZONE); - asctimeFormat.setTimeZone(GMT_ZONE); - } + public final static ThreadLocal oldCookieFormat = new ThreadLocal() { + @Override + public DateFormat initialValue() { + DateFormat result = new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US); + result.setTimeZone(GMT_ZONE); + return result; + } + }; + + + + public final static ThreadLocal rfc1036Format = new ThreadLocal() { + @Override + public DateFormat initialValue() { + DateFormat result = new SimpleDateFormat(rfc1036Pattern, LOCALE_US); + result.setTimeZone(GMT_ZONE); + return result; + } + }; + + public final static ThreadLocal asctimeFormat = new ThreadLocal() { + @Override + public DateFormat initialValue() { + DateFormat result = new SimpleDateFormat(asctimePattern, LOCALE_US); + result.setTimeZone(GMT_ZONE); + return result; + } + }; }