markt       2005/02/14 12:29:29

  Modified:    jasper2/src/share/org/apache/jasper/util Tag:
                        tomcat_4_branch SystemLogHandler.java
  Log:
  Port fix for 33368 fromTC5. Fix leak in swallowOutput
   - Patch submitted by Rainer Jung.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +8 -11     
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/util/SystemLogHandler.java
  
  Index: SystemLogHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/util/SystemLogHandler.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SystemLogHandler.java     25 Aug 2004 20:56:15 -0000      1.1.2.2
  +++ SystemLogHandler.java     14 Feb 2005 20:29:29 -0000      1.1.2.3
  @@ -19,8 +19,6 @@
   import java.io.PrintStream;
   import java.io.IOException;
   
  -import java.util.Hashtable;
  -
   
   /**
    * This helper class may be used to do sophisticated redirection of 
  @@ -55,13 +53,13 @@
       /**
        * Thread <-> PrintStream associations.
        */
  -    protected static Hashtable streams = new Hashtable();
  +    protected static ThreadLocal streams = new ThreadLocal();
   
   
       /**
        * Thread <-> ByteArrayOutputStream associations.
        */
  -    protected static Hashtable data = new Hashtable();
  +    protected static ThreadLocal data = new ThreadLocal();
   
   
       // --------------------------------------------------------- Public 
Methods
  @@ -72,9 +70,8 @@
        */
       public static void setThread() {
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
  -        PrintStream ps = new PrintStream(baos);
  -        data.put(Thread.currentThread(), baos);
  -        streams.put(Thread.currentThread(), ps);
  +        data.set(baos);
  +        streams.set(new PrintStream(baos));
       }
   
   
  @@ -83,12 +80,12 @@
        */
       public static String unsetThread() {
           ByteArrayOutputStream baos = 
  -            (ByteArrayOutputStream) data.get(Thread.currentThread());
  +            (ByteArrayOutputStream) data.get();
           if (baos == null) {
               return null;
           }
  -        streams.remove(Thread.currentThread());
  -        data.remove(Thread.currentThread());
  +        streams.set(null);
  +        data.set(null);
           return baos.toString();
       }
   
  @@ -100,7 +97,7 @@
        * Find PrintStream to which the output must be written to.
        */
       protected PrintStream findStream() {
  -        PrintStream ps = (PrintStream) streams.get(Thread.currentThread());
  +        PrintStream ps = (PrintStream) streams.get();
           if (ps == null) {
               ps = out;
           }
  
  
  

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

Reply via email to