Author: markt
Date: Thu Oct  7 14:05:51 2010
New Revision: 1005452

URL: http://svn.apache.org/viewvc?rev=1005452&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49972
Address potential thread safety issues.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java?rev=1005452&r1=1005451&r2=1005452&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java Thu 
Oct  7 14:05:51 2010
@@ -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<Long, String> formatCache = 
+    private static final ConcurrentHashMap<Long, String> formatCache = 
         new ConcurrentHashMap<Long, String>(CACHE_SIZE);
 
 
     /**
      * Parser cache.
      */
-    protected static final ConcurrentHashMap<String, Long> parseCache = 
+    private static final ConcurrentHashMap<String, Long> parseCache = 
         new ConcurrentHashMap<String, Long>(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;
                 }
             }
         }



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

Reply via email to