From 4eedf5766597e7fd34277ebb4b5f061cf75d214f Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 30 Jun 2009 18:30:45 +0000 Subject: [PATCH] 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 --- java/org/apache/catalina/valves/AccessLogValve.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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(); } -- 2.11.0