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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to