From: markt Date: Tue, 30 Jun 2009 18:30:45 +0000 (+0000) Subject: Use statics to reduce number of instances to one per thread rather than one per threa... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4eedf5766597e7fd34277ebb4b5f061cf75d214f;p=tomcat7.0 Use statics to reduce number of instances to one per thread rather than one per thread per access log. Also make thread local final as per discussion on dev list. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@789865 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/valves/AccessLogValve.java b/java/org/apache/catalina/valves/AccessLogValve.java index 74b847f5d..453d27ebd 100644 --- a/java/org/apache/catalina/valves/AccessLogValve.java +++ b/java/org/apache/catalina/valves/AccessLogValve.java @@ -248,7 +248,7 @@ public class AccessLogValve * is true. */ protected File currentLogFile = null; - private class AccessDateStruct { + private static class AccessDateStruct { private Date currentDate = new Date(); private String currentDateString = null; private SimpleDateFormat dayFormatter = new SimpleDateFormat("dd"); @@ -256,10 +256,11 @@ public class AccessLogValve private SimpleDateFormat yearFormatter = new SimpleDateFormat("yyyy"); private SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss"); public AccessDateStruct() { - dayFormatter.setTimeZone(timezone); - monthFormatter.setTimeZone(timezone); - yearFormatter.setTimeZone(timezone); - timeFormatter.setTimeZone(timezone); + TimeZone tz = TimeZone.getDefault(); + dayFormatter.setTimeZone(tz); + monthFormatter.setTimeZone(tz); + yearFormatter.setTimeZone(tz); + timeFormatter.setTimeZone(tz); } } @@ -267,7 +268,8 @@ public class AccessLogValve * The system time when we last updated the Date that this valve * uses for log lines. */ - private ThreadLocal currentDateStruct = new ThreadLocal() { + private static final ThreadLocal currentDateStruct = + new ThreadLocal() { protected AccessDateStruct initialValue() { return new AccessDateStruct(); }