From 220d01b8bf0e391823ae62b820603a6ac7eac067 Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 7 Oct 2010 14:05:51 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49972 Address potential thread safety issues. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1005452 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tomcat/util/http/FastHttpDateFormat.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java index 0409c1f12..fa16d32fd 100644 --- a/java/org/apache/tomcat/util/http/FastHttpDateFormat.java +++ b/java/org/apache/tomcat/util/http/FastHttpDateFormat.java @@ -36,28 +36,28 @@ public final class FastHttpDateFormat { // -------------------------------------------------------------- Variables - protected static final int CACHE_SIZE = + private static final int CACHE_SIZE = Integer.parseInt(System.getProperty("org.apache.tomcat.util.http.FastHttpDateFormat.CACHE_SIZE", "1000")); /** * HTTP date format. */ - protected static final SimpleDateFormat format = + private static final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); /** * The set of SimpleDateFormat formats to use in getDateHeader(). */ - protected static final SimpleDateFormat formats[] = { + private static final SimpleDateFormat formats[] = { new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) }; - protected final static TimeZone gmtZone = TimeZone.getTimeZone("GMT"); + private static final TimeZone gmtZone = TimeZone.getTimeZone("GMT"); /** @@ -77,26 +77,26 @@ public final class FastHttpDateFormat { /** * Instant on which the currentDate object was generated. */ - protected static long currentDateGenerated = 0L; + private static volatile long currentDateGenerated = 0L; /** * Current formatted date. */ - protected static String currentDate = null; + private static String currentDate = null; /** * Formatter cache. */ - protected static final ConcurrentHashMap formatCache = + private static final ConcurrentHashMap formatCache = new ConcurrentHashMap(CACHE_SIZE); /** * Parser cache. */ - protected static final ConcurrentHashMap parseCache = + private static final ConcurrentHashMap parseCache = new ConcurrentHashMap(CACHE_SIZE); @@ -112,8 +112,8 @@ public final class FastHttpDateFormat { if ((now - currentDateGenerated) > 1000) { synchronized (format) { if ((now - currentDateGenerated) > 1000) { - currentDateGenerated = now; currentDate = format.format(new Date(now)); + currentDateGenerated = now; } } } -- 2.11.0