Author: fhanik
Date: Wed Apr 12 13:57:55 2006
New Revision: 393611

URL: http://svn.apache.org/viewcvs?rev=393611&view=rev
Log:
http://issues.apache.org/bugzilla/show_bug.cgi?id=33368
Already applied to 5.5, backport to 5.0
Fixed provided by Rainer Jung

Modified:
    
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/log/SystemLogHandler.java

Modified: 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/log/SystemLogHandler.java
URL: 
http://svn.apache.org/viewcvs/tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/log/SystemLogHandler.java?rev=393611&r1=393610&r2=393611&view=diff
==============================================================================
--- 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/log/SystemLogHandler.java
 (original)
+++ 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/log/SystemLogHandler.java
 Wed Apr 12 13:57:55 2006
@@ -20,6 +20,7 @@
 import java.io.PrintStream;
 import java.util.Hashtable;
 import java.util.Stack;
+import java.util.EmptyStackException;
 
 /**
  * This helper class may be used to do sophisticated redirection of 
@@ -58,7 +59,7 @@
     /**
      * Thread <-> CaptureLog associations.
      */
-    protected static Hashtable logs = new Hashtable();
+    protected static ThreadLocal logs = new ThreadLocal();
 
 
     /**
@@ -75,19 +76,20 @@
      */
     public static void startCapture() {
         CaptureLog log = null;
-
-        // Synchronized for Bugzilla 31018
-        synchronized(reuse) {
-            log = reuse.isEmpty() ? new CaptureLog() : (CaptureLog)reuse.pop();
+        if (!reuse.isEmpty()) {
+            try {
+                log = (CaptureLog)reuse.pop();
+            } catch (EmptyStackException e) {
+                log = new CaptureLog();
+            }
+        } else {
+            log = new CaptureLog();
         }
-
-        Thread thread = Thread.currentThread();
-        Stack stack = (Stack)logs.get(thread);
+        Stack stack = (Stack)logs.get();
         if (stack == null) {
             stack = new Stack();
-            logs.put(thread, stack);
+            logs.set(stack);
         }
-
         stack.push(log);
     }
 
@@ -96,7 +98,7 @@
      * Stop capturing thread's output and return captured data as a String.
      */
     public static String stopCapture() {
-        Stack stack = (Stack)logs.get(Thread.currentThread());
+        Stack stack = (Stack)logs.get();
         if (stack == null || stack.isEmpty()) {
             return null;
         }
@@ -118,7 +120,7 @@
      * Find PrintStream to which the output must be written to.
      */
     protected PrintStream findStream() {
-        Stack stack = (Stack)logs.get(Thread.currentThread());
+        Stack stack = (Stack)logs.get();
         if (stack != null && !stack.isEmpty()) {
             CaptureLog log = (CaptureLog)stack.peek();
             if (log != null) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to