Simplify, simplify. Thanks to sebb.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 20 Jun 2009 17:04:49 +0000 (17:04 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 20 Jun 2009 17:04:49 +0000 (17:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@786862 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/valves/AccessLogValve.java

index 86f1092..e72b717 100644 (file)
@@ -888,23 +888,23 @@ public class AccessLogValve
     /**
      * write local IP address - %A
      */
-    protected class LocalAddrElement implements AccessLogElement {
+    protected static class LocalAddrElement implements AccessLogElement {
         
-        private ThreadLocal<String> value = new ThreadLocal<String>() {
-            protected String initialValue() {
-                String init;
-                try {
-                    init = InetAddress.getLocalHost().getHostAddress();
-                } catch (Throwable e) {
-                    init = "127.0.0.1";
-                }
-                return init;
+        private static final String LOCAL_ADDR_VALUE;
+
+        static {
+            String init;
+            try {
+                init = InetAddress.getLocalHost().getHostAddress();
+            } catch (Throwable e) {
+                init = "127.0.0.1";
             }
-        };
+            LOCAL_ADDR_VALUE = init;
+        }
         
         public void addElement(StringBuffer buf, Date date, Request request,
                 Response response, long time) {
-            buf.append(value.get());
+            buf.append(LOCAL_ADDR_VALUE);
         }
     }