cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log SystemLogHandler.java
yoavs 2004/09/02 11:48:47 Modified:util/java/org/apache/tomcat/util/log SystemLogHandler.java Log: Addressed Bugzilla 31018. Revision ChangesPath 1.5 +6 -4 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log/SystemLogHandler.java Index: SystemLogHandler.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log/SystemLogHandler.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SystemLogHandler.java 24 Feb 2004 08:50:06 - 1.4 +++ SystemLogHandler.java 2 Sep 2004 18:48:47 - 1.5 @@ -75,17 +75,19 @@ */ public static void startCapture() { CaptureLog log = null; -if (!reuse.isEmpty()) { -log = (CaptureLog)reuse.pop(); -} else { -log = new CaptureLog(); + +// Synchronized for Bugzilla 31018 +synchronized(reuse) { +log = reuse.isEmpty() ? new CaptureLog() : (CaptureLog)reuse.pop(); } + Thread thread = Thread.currentThread(); Stack stack = (Stack)logs.get(thread); if (stack == null) { stack = new Stack(); logs.put(thread, stack); } + stack.push(log); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log SystemLogHandler.java
yoavs 2004/09/02 11:51:00 Modified:webapps/docs Tag: TOMCAT_5_0 changelog.xml util/java/org/apache/tomcat/util/log Tag: TOMCAT_5_0 SystemLogHandler.java Log: Addressed Bugzilla 31018. Revision ChangesPath No revision No revision 1.70.2.28 +7 -0 jakarta-tomcat-catalina/webapps/docs/changelog.xml Index: changelog.xml === RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v retrieving revision 1.70.2.27 retrieving revision 1.70.2.28 diff -u -r1.70.2.27 -r1.70.2.28 --- changelog.xml 2 Sep 2004 18:45:38 - 1.70.2.27 +++ changelog.xml 2 Sep 2004 18:51:00 - 1.70.2.28 @@ -76,6 +76,13 @@ /fix /changelog /subsection + subsection name=Coyote +changelog + fix +bug31018/bug: Race condition in SystemLogHandler. (yoavs) + /fix +/changelog + /subsection /section section name=Tomcat 5.0.28 (yoavs) No revision No revision 1.4.2.1 +6 -4 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log/SystemLogHandler.java Index: SystemLogHandler.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log/SystemLogHandler.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- SystemLogHandler.java 24 Feb 2004 08:50:06 - 1.4 +++ SystemLogHandler.java 2 Sep 2004 18:51:00 - 1.4.2.1 @@ -75,17 +75,19 @@ */ public static void startCapture() { CaptureLog log = null; -if (!reuse.isEmpty()) { -log = (CaptureLog)reuse.pop(); -} else { -log = new CaptureLog(); + +// Synchronized for Bugzilla 31018 +synchronized(reuse) { +log = reuse.isEmpty() ? new CaptureLog() : (CaptureLog)reuse.pop(); } + Thread thread = Thread.currentThread(); Stack stack = (Stack)logs.get(thread); if (stack == null) { stack = new Stack(); logs.put(thread, stack); } + stack.push(log); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log SystemLogHandler.java
glenn 2002/06/26 05:36:00 Modified:util/java/org/apache/tomcat/util/log SystemLogHandler.java Log: Bug fix, can't peek if a stack is empty Revision ChangesPath 1.2 +7 -10 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log/SystemLogHandler.java Index: SystemLogHandler.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log/SystemLogHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SystemLogHandler.java 23 May 2002 17:21:09 - 1.1 +++ SystemLogHandler.java 26 Jun 2002 12:36:00 - 1.2 @@ -124,18 +124,15 @@ public static void startCapture() { CaptureLog log = null; if (!reuse.isEmpty()) { -try { -log = (CaptureLog)reuse.pop(); -} catch(Exception e) { -} -} -if (log == null) { +log = (CaptureLog)reuse.pop(); +} else { log = new CaptureLog(); } -Stack stack = (Stack)logs.get(Thread.currentThread()); +Thread thread = Thread.currentThread(); +Stack stack = (Stack)logs.get(thread); if (stack == null) { stack = new Stack(); -logs.put(Thread.currentThread(), stack); +logs.put(thread, stack); } stack.push(log); } @@ -146,7 +143,7 @@ */ public static String stopCapture() { Stack stack = (Stack)logs.get(Thread.currentThread()); -if (stack == null) { +if (stack == null || stack.isEmpty()) { return null; } CaptureLog log = (CaptureLog)stack.pop(); @@ -168,7 +165,7 @@ */ protected PrintStream findStream() { Stack stack = (Stack)logs.get(Thread.currentThread()); -if (stack != null) { +if (stack != null !stack.isEmpty()) { CaptureLog log = (CaptureLog)stack.peek(); if (log != null) { PrintStream ps = log.getStream(); -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log SystemLogHandler.java CaptureLog.java
glenn 02/05/23 10:21:09 Added: util/java/org/apache/tomcat/util/log SystemLogHandler.java CaptureLog.java Log: Custome logger which can be used to capture System.out and System.err to a buffer for later use. Used by Tomcat 4 to capture this output when handling a request so any output can be sent to the webapp context log instead of catalina.out. Revision ChangesPath 1.1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/log/SystemLogHandler.java Index: SystemLogHandler.java === /* * * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in *the documentation and/or other materials provided with the *distribution. * * 3. The end-user documentation included with the redistribution, if *any, must include the following acknowlegement: * This product includes software developed by the *Apache Software Foundation (http://www.apache.org/). *Alternately, this acknowlegement may appear in the software itself, *if and wherever such third-party acknowlegements normally appear. * * 4. The names The Jakarta Project, Tomcat, and Apache Software *Foundation must not be used to endorse or promote products derived *from this software without prior written permission. For written *permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called Apache *nor may Apache appear in their names without prior written *permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * http://www.apache.org/. * */ package org.apache.tomcat.util.log; import java.io.ByteArrayOutputStream; import java.io.Writer; import java.io.PrintStream; import java.io.PrintWriter; import java.io.FileWriter; import java.io.File; import java.io.OutputStreamWriter; import java.io.IOException; import java.io.StringWriter; import java.util.Hashtable; import java.util.Stack; /** * This helper class may be used to do sophisticated redirection of * System.out and System.err on a per Thread basis. * * A stack is implemented per Thread so that nested startCapture * and stopCapture can be used. * * @author Remy Maucherat * @author Glenn L. Nielsen */ public class SystemLogHandler extends PrintStream { // --- Constructors /** * Construct the handler to capture the output of the given steam. */ public SystemLogHandler(PrintStream wrapped) { super(wrapped); out = wrapped; } // - Instance Variables /** * Wrapped PrintStream. */ protected PrintStream out = null; /** * Thread - CaptureLog associations. */ protected static Hashtable logs = new Hashtable(); /** * Spare CaptureLog ready for reuse. */ protected static Stack reuse = new Stack(); // - Public Methods /** * Start capturing