You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fu...@apache.org on 2003/08/05 20:41:50 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardWrapperValve.java

funkman     2003/08/05 11:41:50

  Modified:    catalina/src/share/org/apache/catalina/valves
                        ErrorReportValve.java
               catalina/src/share/org/apache/catalina/core
                        StandardWrapperValve.java
  Log:
  Experiment: Use PropertyUtils to obtain the rootCause. This way we can
  also drill into nested JspExceptions or another Throwable object
  which has a 'rootCause' property which returns a Throwable.
  
  Revision  Changes    Path
  1.9       +16 -7     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves/ErrorReportValve.java
  
  Index: ErrorReportValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves/ErrorReportValve.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ErrorReportValve.java	2 Aug 2003 17:31:04 -0000	1.8
  +++ ErrorReportValve.java	5 Aug 2003 18:41:49 -0000	1.9
  @@ -95,6 +95,7 @@
   import org.apache.catalina.util.ServerInfo;
   import org.apache.catalina.util.StringManager;
   
  +import org.apache.commons.beanutils.PropertyUtils;
   
   /**
    * <p>Implementation of a Valve that outputs HTML error pages.</p>
  @@ -335,10 +336,18 @@
                   sb.append(stackTrace);
                   sb.append("</pre></p>");
                   // In case root cause is somehow heavily nested
  -                if (rootCause instanceof ServletException)
  -                    rootCause = ((ServletException) rootCause).getRootCause();
  -                else
  +                try {
  +                    rootCause = (Throwable)PropertyUtils.getProperty
  +                                                (rootCause, "rootCause");
  +                } catch (ClassCastException e) {
                       rootCause = null;
  +                } catch (IllegalAccessException e) {
  +                    rootCause = null;
  +                } catch (NoSuchMethodException e) {
  +                    rootCause = null;
  +                } catch (java.lang.reflect.InvocationTargetException e) {
  +                    rootCause = null;
  +                }
               }
   
               sb.append("<p><b>");
  
  
  
  1.20      +30 -16    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- StandardWrapperValve.java	22 Jul 2003 21:01:26 -0000	1.19
  +++ StandardWrapperValve.java	5 Aug 2003 18:41:50 -0000	1.20
  @@ -82,6 +82,7 @@
   import org.apache.catalina.util.StringManager;
   import org.apache.catalina.valves.ValveBase;
   import org.apache.tomcat.util.buf.MessageBytes;
  +import org.apache.commons.beanutils.PropertyUtils;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -145,7 +146,7 @@
           HttpRequest hrequest = (HttpRequest) request;
           Servlet servlet = null;
           HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  -        HttpServletResponse hres = 
  +        HttpServletResponse hres =
               (HttpServletResponse) response.getResponse();
   
           // Check for the application being marked unavailable
  @@ -157,7 +158,7 @@
   
           // Check for the servlet being marked unavailable
           if (!unavailable && wrapper.isUnavailable()) {
  -            log(sm.getString("standardWrapper.isUnavailable", 
  +            log(sm.getString("standardWrapper.isUnavailable",
                                wrapper.getName()));
               if (hres == null) {
                   ;       // NOTE - Not much we can do generically
  @@ -232,13 +233,13 @@
               (ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
                ApplicationFilterFactory.REQUEST_INTEGER);
           hreq.setAttribute
  -            (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR, 
  +            (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
                requestPathMB);
           // Create the filter chain for this request
  -        ApplicationFilterFactory factory = 
  +        ApplicationFilterFactory factory =
               ApplicationFilterFactory.getInstance();
  -        ApplicationFilterChain filterChain = 
  -            factory.createFilterChain((ServletRequest) request, 
  +        ApplicationFilterChain filterChain =
  +            factory.createFilterChain((ServletRequest) request,
                                         wrapper, servlet);
   
           // Call the filter chain for this request
  @@ -276,20 +277,33 @@
                   hres.sendError(HttpServletResponse.SC_NOT_FOUND,
                               sm.getString("standardWrapper.notFound",
                                           wrapper.getName()));
  -            }            
  +            }
               // Do not save exception in 'throwable', because we
               // do not want to do exception(request, response, e) processing
           } catch (ServletException e) {
               hreq.removeAttribute(Globals.JSP_FILE_ATTR);
               Throwable rootCause = e;
  -            while (rootCause instanceof ServletException) {
  -                Throwable t = ((ServletException) rootCause).getRootCause();
  -                if (t != null) {
  -                    rootCause = t;
  -                } else {
  -                    break;
  +            Throwable rootCauseCheck = null;
  +
  +            // Extra aggressive rootCause finding
  +            do {
  +                try {
  +                    rootCauseCheck = (Throwable)PropertyUtils.getProperty
  +                                                (rootCause, "rootCause");
  +                    if (rootCauseCheck!=null)
  +                        rootCause = rootCauseCheck;
  +
  +                } catch (ClassCastException ex) {
  +                    rootCauseCheck = null;
  +                } catch (IllegalAccessException ex) {
  +                    rootCauseCheck = null;
  +                } catch (NoSuchMethodException ex) {
  +                    rootCauseCheck = null;
  +                } catch (java.lang.reflect.InvocationTargetException ex) {
  +                    rootCauseCheck = null;
                   }
  -            }
  +            } while (rootCauseCheck != null);
  +
               log(sm.getString("standardWrapper.serviceException",
                                wrapper.getName()), rootCause);
               throwable = e;
  @@ -464,7 +478,7 @@
       }
   
       // Don't register in JMX
  -    
  +
       public ObjectName createObjectName(String domain, ObjectName parent)
               throws MalformedObjectNameException
       {
  
  
  

Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardWrapperValve.java

Posted by Remy Maucherat <re...@apache.org>.
funkman@apache.org wrote:

> funkman     2003/08/05 11:41:50
> 
>   Modified:    catalina/src/share/org/apache/catalina/valves
>                         ErrorReportValve.java
>                catalina/src/share/org/apache/catalina/core
>                         StandardWrapperValve.java
>   Log:
>   Experiment: Use PropertyUtils to obtain the rootCause. This way we can
>   also drill into nested JspExceptions or another Throwable object
>   which has a 'rootCause' property which returns a Throwable.

That sounds like a very promising idea.
There's at least another place like that, in the RequestDispatcher.

Remy



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


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardWrapperValve.java

Posted by Remy Maucherat <re...@apache.org>.
funkman@apache.org wrote:

> funkman     2003/08/05 11:41:50
> 
>   Modified:    catalina/src/share/org/apache/catalina/valves
>                         ErrorReportValve.java
>                catalina/src/share/org/apache/catalina/core
>                         StandardWrapperValve.java
>   Log:
>   Experiment: Use PropertyUtils to obtain the rootCause. This way we can
>   also drill into nested JspExceptions or another Throwable object
>   which has a 'rootCause' property which returns a Throwable.

That sounds like a very promising idea.
There's at least another place like that, in the RequestDispatcher.

Remy