remm        2005/01/21 05:11:02

  Modified:    catalina/src/share/org/apache/catalina/valves
                        ErrorReportValve.java
  Log:
  - 33033: Don't do anything to the response if data has already been written. 
I didn't attempt to really
    reproduce the bug report, but the algorithm seemed to indicate that 
thecontent type would
    be modified. Checking before doing anything is also a lot more efficient, 
as we save the generation of
    the error report.
  
  Revision  Changes    Path
  1.25      +19 -37    
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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ErrorReportValve.java     23 Sep 2004 06:56:08 -0000      1.24
  +++ ErrorReportValve.java     21 Jan 2005 13:11:02 -0000      1.25
  @@ -135,7 +135,7 @@
           try {
               report(request, response, throwable);
           } catch (Throwable tt) {
  -            tt.printStackTrace();
  +            ;
           }
   
       }
  @@ -173,19 +173,10 @@
           int statusCode = response.getStatus();
   
           // Do nothing on a 1xx, 2xx and 3xx status
  -        if (statusCode < 400)
  +        // Do nothing if anything has been written already
  +        if ((statusCode < 400) || (response.getContentCount() > 0))
               return;
   
  -        // FIXME: Reset part of the request
  -/*
  -        try {
  -            if (hresponse.isError())
  -                hresponse.reset(statusCode, message);
  -        } catch (IllegalStateException e) {
  -            ;
  -        }
  -*/
  -
           Throwable rootCause = null;
   
           if (throwable != null) {
  @@ -198,7 +189,7 @@
           String message = RequestUtil.filter(response.getMessage());
           if (message == null)
               message = "";
  -    
  +
           // Do nothing if there is no report for the specified status code
           String report = null;
           try {
  @@ -281,34 +272,25 @@
           sb.append("</body></html>");
   
           try {
  -
  -          try {
  -
  -            response.setContentType("text/html");
  -            response.setCharacterEncoding("utf-8");
  -
  -          } catch (Throwable t) {
  -
  -             if (container.getLogger().isDebugEnabled())
  -               container.getLogger().debug("status.setContentType", t);
  -
  -          }
  -
  -          Writer writer = response.getReporter();
  -
  -          if (writer != null) {
  -            // If writer is null, it's an indication that the response has
  -            // been hard committed already, which should never happen
  -            writer.write(sb.toString());
  -          }
  -
  +            try {
  +                response.setContentType("text/html");
  +                response.setCharacterEncoding("utf-8");
  +            } catch (Throwable t) {
  +                if (container.getLogger().isDebugEnabled())
  +                    container.getLogger().debug("status.setContentType", t);
  +            }
  +            Writer writer = response.getReporter();
  +            if (writer != null) {
  +                // If writer is null, it's an indication that the response 
has
  +                // been hard committed already, which should never happen
  +                writer.write(sb.toString());
  +            }
           } catch (IOException e) {
               ;
  -
           } catch (IllegalStateException e) {
               ;
           }
  -
  +        
       }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to