Author: markt
Date: Fri Oct 26 18:10:33 2012
New Revision: 1402600
URL: http://svn.apache.org/viewvc?rev=1402600&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54044
Fix off-by-one errors and ensure offset is set when requested value is within
cacheSize of the current cache range.
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=1402600&r1=1402599&r2=1402600&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Fri Oct 26
18:10:33 2012
@@ -310,9 +310,9 @@ public class AccessLogValve extends Valv
private String previousFormat = "";
/* First second contained in cache */
- private long first = 0L;
+ private long first = Long.MIN_VALUE;
/* Last second contained in cache */
- private long last = 0L;
+ private long last = Long.MIN_VALUE;
/* Index of "first" in the cyclic cache */
private int offset = 0;
/* Helper object to be able to call SimpleDateFormat.format(). */
@@ -387,14 +387,16 @@ public class AccessLogValve extends Valv
for (int i = 1; i < seconds - last; i++) {
cache[(index + cacheSize - i) % cacheSize] = null;
}
- first = seconds - cacheSize;
+ first = seconds - (cacheSize - 1);
last = seconds;
+ offset = (index + 1) % cacheSize;
} else if (seconds < first) {
for (int i = 1; i < first - seconds; i++) {
cache[(index + i) % cacheSize] = null;
}
first = seconds;
- last = seconds + cacheSize;
+ last = seconds + (cacheSize - 1);
+ offset = index;
}
/* Last step: format new timestamp either using
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]