Address kkolinko's review comments
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 20 Jun 2011 18:19:08 +0000 (18:19 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 20 Jun 2011 18:19:08 +0000 (18:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1137731 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/juli/OneLineFormatter.java
webapps/docs/changelog.xml

index f7e32c4..30e9372 100644 (file)
@@ -47,10 +47,10 @@ public class OneLineFormatter extends Formatter {
     private final SimpleDateFormat monthFormatter = new SimpleDateFormat("MM");
     private final SimpleDateFormat yearFormatter = new SimpleDateFormat("yyyy");
     private final SimpleDateFormat timeFormatter =
-        new SimpleDateFormat("HH:mm:ss.S");
+        new SimpleDateFormat("HH:mm:ss.SSS");
     
-    private Date currentDate;
-    private String currentDateString;
+    private volatile Date currentDate;
+    private volatile String currentDateString;
 
     @Override
     public String format(LogRecord record) {
@@ -71,7 +71,7 @@ public class OneLineFormatter extends Formatter {
         
         // Message
         sb.append(' ');
-        sb.append(record.getMessage());
+        sb.append(formatMessage(record));
         
         // Stack trace
         if (record.getThrown() != null) {
@@ -89,10 +89,10 @@ public class OneLineFormatter extends Formatter {
         return sb.toString();
     }
 
-    public void addTimestamp(StringBuilder buf, Date date) {
-        if (currentDate != date) {
+    protected void addTimestamp(StringBuilder buf, Date date) {
+        if (currentDate.getTime() != date.getTime()) {
             synchronized (this) {
-                if (currentDate != date) {
+                if (currentDate.getTime() != date.getTime()) {
                     StringBuilder current = new StringBuilder(32);
                     current.append(dayFormatter.format(date)); // Day
                     current.append('-');
index dc6e7f2..3bbbdc9 100644 (file)
         when Tomcat was shutdown. This fix ensures that that work directory for
         an application is not deleted when Tomcat is shutdown. (mark)
       </fix>
+      <fix>
+        Correct issues with JULI&apos;s OneLineFormatter including: correctly
+        re-using formatted timestamps when possible; thread-safety issues in
+        tiomstamp formatting; correcting the output of any milliseconds to
+        include leading zeros and formatting any parameters present.
+        (kolinko/markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">