From: markt Date: Mon, 20 Jun 2011 18:19:08 +0000 (+0000) Subject: Address kkolinko's review comments X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=238d428485d771739a43ac8b959b7681806a3528;p=tomcat7.0 Address kkolinko's review comments git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1137731 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/juli/OneLineFormatter.java b/java/org/apache/juli/OneLineFormatter.java index f7e32c43e..30e937259 100644 --- a/java/org/apache/juli/OneLineFormatter.java +++ b/java/org/apache/juli/OneLineFormatter.java @@ -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('-'); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index dc6e7f2f8..3bbbdc98e 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -78,6 +78,13 @@ when Tomcat was shutdown. This fix ensures that that work directory for an application is not deleted when Tomcat is shutdown. (mark) + + Correct issues with JULI'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) +