tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 21834] New: - Endless recursion in log() method if Logger is not set
Date Wed, 23 Jul 2003 20:27:03 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21834>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21834

Endless recursion in log() method if Logger is not set

           Summary: Endless recursion in log() method if Logger is not set
           Product: Tomcat 4
           Version: 4.1.24
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: vishy@borland.com


StandaredWrapperValve.log() goes in to endless recursion because of a change 
that was recenly made to the  StandardWrapperValve.java

Steps to reproduce:

1. Comment out the all loggers from server.xml

2. Deploy a servlet similar to the one below:

public class Servlet1
    extends GenericServlet {

  public void service(ServletRequest request, ServletResponse response) throws
      ServletException, IOException, java.lang.ArithmeticException {

    throw new java.lang.ArithmeticException("This is an ArithmeticException");
  }
}

3. Hit the servlet using a browser (http://localhost:8080/error/servlet1 in my 
case).

4. The run time exception is caught and an attempt is made to log it. However, 
if the logger is not set, log is entered recursively. 

Here is the offending code:
    private void log(String message, Throwable throwable) {

        Logger logger = null;
        if (container != null)
            logger = container.getLogger();
        if (logger != null)
            logger.log("StandardWrapperValve[" + container.getName() + "]: "
                       + message, throwable);
        else {
            String containerName = null;
            if (container != null)
                containerName = container.getName();
            log( "StandardWrapperValve[" + containerName
                       + "]: " + message, throwable);
        }

    }

The fix is simple:

Replace the last log above with a System.println. 

I will attach a WAR file if I figure out how to do attachements to bugzilla 
bugs.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message