You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/06/12 19:40:49 UTC

svn commit: r1602246 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/connector/Response.java java/org/apache/catalina/valves/ErrorReportValve.java java/org/apache/coyote/Response.java

Author: markt
Date: Thu Jun 12 17:40:49 2014
New Revision: 1602246

URL: http://svn.apache.org/r1602246
Log:
Backport some clean-up from trunk

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1598242,1598248,1598266-1598267

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java?rev=1602246&r1=1602245&r2=1602246&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java Thu Jun 12 17:40:49 2014
@@ -504,8 +504,7 @@ public class Response
      *
      * @exception IOException if an input/output error occurs
      */
-    public void finishResponse()
-        throws IOException {
+    public void finishResponse() throws IOException {
         // Writing leftover bytes
         outputBuffer.close();
     }
@@ -515,7 +514,7 @@ public class Response
      * Return the content length that was set or calculated for this Response.
      */
     public int getContentLength() {
-        return (coyoteResponse.getContentLength());
+        return coyoteResponse.getContentLength();
     }
 
 
@@ -525,7 +524,7 @@ public class Response
      */
     @Override
     public String getContentType() {
-        return (coyoteResponse.getContentType());
+        return coyoteResponse.getContentType();
     }
 
 
@@ -659,7 +658,6 @@ public class Response
             writer = new CoyoteWriter(outputBuffer);
         }
         return writer;
-
     }
 
 
@@ -668,7 +666,7 @@ public class Response
      */
     @Override
     public boolean isCommitted() {
-        return (coyoteResponse.isCommitted());
+        return coyoteResponse.isCommitted();
     }
 
 
@@ -680,10 +678,9 @@ public class Response
      */
     @Override
     public void reset() {
-
-        if (included)
-         {
-            return;     // Ignore any call from an included servlet
+        // Ignore any call from an included servlet
+        if (included) {
+            return;
         }
 
         coyoteResponse.reset();
@@ -1287,8 +1284,7 @@ public class Response
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public void sendError(int status)
-        throws IOException {
+    public void sendError(int status) throws IOException {
         sendError(status, null);
     }
 
@@ -1304,8 +1300,7 @@ public class Response
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public void sendError(int status, String message)
-        throws IOException {
+    public void sendError(int status, String message) throws IOException {
 
         if (isCommitted()) {
             throw new IllegalStateException
@@ -1332,7 +1327,6 @@ public class Response
 
         // Cause the response to be finished (from the application perspective)
         setSuspended(true);
-
     }
 
 
@@ -1346,8 +1340,7 @@ public class Response
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public void sendRedirect(String location)
-        throws IOException {
+    public void sendRedirect(String location) throws IOException {
 
         if (isCommitted()) {
             throw new IllegalStateException
@@ -1379,7 +1372,6 @@ public class Response
 
         // Cause the response to be finished (from the application perspective)
         setSuspended(true);
-
     }
 
 
@@ -1412,7 +1404,6 @@ public class Response
         }
 
         setHeader(name, FastHttpDateFormat.formatDate(value, format));
-
     }
 
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?rev=1602246&r1=1602245&r2=1602246&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java Thu Jun 12 17:40:49 2014
@@ -16,7 +16,6 @@
  */
 package org.apache.catalina.valves;
 
-
 import java.io.IOException;
 import java.io.Writer;
 import java.util.Scanner;
@@ -86,7 +85,9 @@ public class ErrorReportValve extends Va
 
     /**
      * Invoke the next Valve in the sequence. When the invoke returns, check
-     * the response state, and output an error report is necessary.
+     * the response state. If the status code is greater than or equal to 400
+     * or an uncaught exception was thrown then the error handling will be
+     * triggered.
      *
      * @param request The servlet request to be processed
      * @param response The servlet response to be created
@@ -95,8 +96,7 @@ public class ErrorReportValve extends Va
      * @exception ServletException if a servlet error occurs
      */
     @Override
-    public void invoke(Request request, Response response)
-        throws IOException, ServletException {
+    public void invoke(Request request, Response response) throws IOException, ServletException {
 
         // Perform the request
         getNext().invoke(request, response);
@@ -105,8 +105,7 @@ public class ErrorReportValve extends Va
             return;
         }
 
-        Throwable throwable =
-                (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
+        Throwable throwable = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
 
         if (request.isAsyncStarted() && ((response.getStatus() < 400 &&
                 throwable == null) || request.isAsyncDispatching())) {
@@ -114,7 +113,6 @@ public class ErrorReportValve extends Va
         }
 
         if (throwable != null) {
-
             // The response is an error
             response.setError();
 
@@ -125,9 +123,7 @@ public class ErrorReportValve extends Va
                 // Ignore
             }
 
-            response.sendError
-                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
 
         response.setSuspended(false);
@@ -155,16 +151,14 @@ public class ErrorReportValve extends Va
      * @param throwable The exception that occurred (which possibly wraps
      *  a root cause exception
      */
-    protected void report(Request request, Response response,
-                          Throwable throwable) {
+    protected void report(Request request, Response response, Throwable throwable) {
 
         // Do nothing on non-HTTP responses
         int statusCode = response.getStatus();
 
         // Do nothing on a 1xx, 2xx and 3xx status
         // Do nothing if anything has been written already
-        if (statusCode < 400 || response.getContentWritten() > 0 ||
-                !response.isError()) {
+        if (statusCode < 400 || response.getContentWritten() > 0 || !response.isError()) {
             return;
         }
 
@@ -173,8 +167,7 @@ public class ErrorReportValve extends Va
             if (throwable != null) {
                 String exceptionMessage = throwable.getMessage();
                 if (exceptionMessage != null && exceptionMessage.length() > 0) {
-                    message = RequestUtil.filter(
-                            (new Scanner(exceptionMessage)).nextLine());
+                    message = RequestUtil.filter((new Scanner(exceptionMessage)).nextLine());
                 }
             }
             if (message == null) {

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java?rev=1602246&r1=1602245&r2=1602246&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java Thu Jun 12 17:40:49 2014
@@ -237,7 +237,7 @@ public final class Response {
      * request processing.
      */
     public void setErrorException(Exception ex) {
-    errorException = ex;
+        errorException = ex;
     }
 
 
@@ -256,10 +256,8 @@ public final class Response {
 
 
     // -------------------- Methods --------------------
-    
-    
-    public void reset() 
-        throws IllegalStateException {
+
+    public void reset() throws IllegalStateException {
         
         // Reset the headers only if this is the main request,
         // not for included
@@ -489,10 +487,6 @@ public final class Response {
         return ret;
     }
     
-    public void setContentLength(int contentLength) {
-        this.contentLength = contentLength;
-    }
-
     public void setContentLength(long contentLength) {
         this.contentLength = contentLength;
     }



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