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 39088] - StandardWrapper getRootCause() infinite loop
Date Mon, 15 Jan 2007 14:38:50 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39088>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39088





------- Additional Comments From wouter.zelle@gmail.com  2007-01-15 06:38 -------
Mark,

If you really want the root cause, you should do this:

public static Throwable getRootCause(ServletException e) {
    Throwable rootCause = e.getRootCause();
    if (rootCause instanceof ServletException
            && rootCause != e) {
        rootCause = getRootCause((ServletException) rootCause);
    } else {
        Throwable deepRootCause;
        do {
            deepRootCause = rootCause.getCause();
            if (rootCause == deepRootCause) {
                return rootCause;
            } else if (deepRootCause != null) {
                rootCause = deepRootCause;
            }
        } while (deepRootCause != null);
    }
    return rootCause;
}

This code is actually far more likely to find the true root cause and as an
added bonus, it uses API's whose implementation you should be able to trust.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message