Author: kkolinko Date: Mon Nov 12 21:04:28 2012 New Revision: 1408459 URL: http://svn.apache.org/viewvc?rev=1408459&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54044 Correct bug in timestamp cache used by org.apache.juli.OneLineFormatter that meant entries could be made with an earlier timestamp than the true timestamp.
It is backport of r1402624 of TC7 (r1402622 of trunk) Modified: tomcat/tc6.0.x/branches/tomcat6-testing/java/org/apache/juli/DateFormatCache.java Modified: tomcat/tc6.0.x/branches/tomcat6-testing/java/org/apache/juli/DateFormatCache.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/branches/tomcat6-testing/java/org/apache/juli/DateFormatCache.java?rev=1408459&r1=1408458&r2=1408459&view=diff ============================================================================== --- tomcat/tc6.0.x/branches/tomcat6-testing/java/org/apache/juli/DateFormatCache.java (original) +++ tomcat/tc6.0.x/branches/tomcat6-testing/java/org/apache/juli/DateFormatCache.java Mon Nov 12 21:04:28 2012 @@ -101,14 +101,14 @@ public class DateFormatCache { private class Cache { /* Second formatted in most recent invocation */ - private long previousSeconds = 0L; + private long previousSeconds = Long.MIN_VALUE; /* Formatted timestamp generated in most recent invocation */ 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(). */ @@ -165,14 +165,16 @@ public class DateFormatCache { 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: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org