Author: markt
Date: Thu Jun  4 15:36:07 2009
New Revision: 781779

URL: http://svn.apache.org/viewvc?rev=781779&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47158
Thread safety issues

Modified:
    tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java

Modified: tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=781779&r1=781778&r2=781779&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Thu Jun  4 
15:36:07 2009
@@ -132,7 +132,7 @@
      * The as-of date for the currently open log file, or a zero-length
      * string if there is no open log file.
      */
-    private String dateStamp = "";
+    private volatile String dateStamp = "";
 
 
     /**
@@ -283,7 +283,7 @@
      */
     private Date currentDate = null;
     
-    private long currentMillis = 0;
+    private volatile long currentMillis = 0;
 
 
     /**
@@ -609,8 +609,8 @@
             }
 
             /* Make sure date is correct */
-            currentDate = new Date(System.currentTimeMillis());
-            dateStamp = fileDateFormatter.format(currentDate);
+            dateStamp = fileDateFormatter.format(
+                    new Date(System.currentTimeMillis()));
 
             open();
             return true;
@@ -650,12 +650,10 @@
             long systime = System.currentTimeMillis();
             if ((systime - rotationLastChecked) > 1000) {
 
-                // We need a new currentDate
-                currentDate = new Date(systime);
                 rotationLastChecked = systime;
 
                 // Check for a change of date
-                String tsDate = fileDateFormatter.format(currentDate);
+                String tsDate = fileDateFormatter.format(new Date(systime));
 
                 // If the date has changed, switch log files
                 if (!dateStamp.equals(tsDate)) {
@@ -681,8 +679,8 @@
                     }
 
                     /* Make sure date is correct */
-                    currentDate = new Date(System.currentTimeMillis());
-                    dateStamp = fileDateFormatter.format(currentDate);
+                    dateStamp = fileDateFormatter.format(
+                            new Date(System.currentTimeMillis()));
 
                     open();
                 }



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

Reply via email to