remm 01/01/10 19:51:54
Modified: catalina/src/share/org/apache/catalina/valves
AccessLogValve.java
Log:
- Fix potential incorrenctly named log files.
Patch submitted by Jason Brittain <[EMAIL PROTECTED]>
- I roll the patch back to TC 4.0, as it's a bug fix (and didn't appear to break
anything).
Revision Changes Path
1.3 +10 -7
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java
Index: AccessLogValve.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AccessLogValve.java 2000/11/30 01:55:31 1.2
+++ AccessLogValve.java 2001/01/11 03:51:53 1.3
@@ -125,7 +125,7 @@
*
* @author Craig R. McClanahan
* @author Jason Brittain
- * @version $Revision: 1.2 $ $Date: 2000/11/30 01:55:31 $
+ * @version $Revision: 1.3 $ $Date: 2001/01/11 03:51:53 $
*/
public final class AccessLogValve
@@ -493,7 +493,7 @@
/**
* Close the currently open log file (if any)
*/
- private void close() {
+ private synchronized void close() {
if (writer == null)
return;
@@ -516,9 +516,10 @@
public void log(String message, Date date) {
// Only do a logfile switch check once a second, max.
- if ((System.currentTimeMillis() - currentDate.getTime()) > 1000) {
+ long systime = System.currentTimeMillis();
+ if ((systime - currentDate.getTime()) > 1000) {
// We need a new currentDate
- currentDate = new Date();
+ currentDate = new Date(systime);
// Check for a change of date
String tsDate = dateFormatter.format(currentDate);
@@ -563,7 +564,7 @@
/**
* Open the new log file for the date specified by <code>dateStamp</code>.
*/
- private void open() {
+ private synchronized void open() {
// Create the directory if necessary
File dir = new File(directory);
@@ -698,8 +699,9 @@
private Date getDate() {
// Only create a new Date once per second, max.
- if ((System.currentTimeMillis() - currentDate.getTime()) > 1000) {
- currentDate = new Date();
+ long systime = System.currentTimeMillis();
+ if ((systime - currentDate.getTime()) > 1000) {
+ currentDate = new Date(systime);
}
return currentDate;
@@ -770,6 +772,7 @@
timeFormatter = new SimpleDateFormat("kk:mm:ss");
timeFormatter.setTimeZone(tz);
currentDate = new Date();
+ dateStamp = dateFormatter.format(currentDate);
open();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]