Add an additional volatile from a review of the associated benchmark tests.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Jun 2009 12:40:56 +0000 (12:40 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Jun 2009 12:40:56 +0000 (12:40 +0000)
Add a sync to deal with the issue filip reported in the 5.5.x status file

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@786483 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/valves/AccessLogValve.java

index 7df2740..d5aba16 100644 (file)
@@ -281,7 +281,7 @@ public class AccessLogValve
      * The system time when we last updated the Date that this valve
      * uses for log lines.
      */
-    private Date currentDate = null;
+    private volatile Date currentDate = null;
     
     private volatile long currentMillis = 0;
 
@@ -690,10 +690,12 @@ public class AccessLogValve
         }
 
         // Log this message
-        if (writer != null) {
-            writer.println(message);
-            if (!buffered) {
-                writer.flush();
+        synchronized(this) {
+            if (writer != null) {
+                writer.println(message);
+                if (!buffered) {
+                    writer.flush();
+                }
             }
         }