From e2073255e2af1d86a7db77ae4e2adaca1bb61ab6 Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 4 Jun 2009 15:36:07 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47158 Thread safety issues git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@781779 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/valves/AccessLogValve.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/java/org/apache/catalina/valves/AccessLogValve.java b/java/org/apache/catalina/valves/AccessLogValve.java index 4fba7e807..60211b887 100644 --- a/java/org/apache/catalina/valves/AccessLogValve.java +++ b/java/org/apache/catalina/valves/AccessLogValve.java @@ -132,7 +132,7 @@ public class AccessLogValve * 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 @@ public class AccessLogValve */ private Date currentDate = null; - private long currentMillis = 0; + private volatile long currentMillis = 0; /** @@ -609,8 +609,8 @@ public class AccessLogValve } /* 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 @@ public class AccessLogValve 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 @@ public class AccessLogValve } /* Make sure date is correct */ - currentDate = new Date(System.currentTimeMillis()); - dateStamp = fileDateFormatter.format(currentDate); + dateStamp = fileDateFormatter.format( + new Date(System.currentTimeMillis())); open(); } -- 2.11.0