You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2010/10/22 16:54:15 UTC

svn commit: r1026351 - /sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java

Author: fmeschbe
Date: Fri Oct 22 14:54:15 2010
New Revision: 1026351

URL: http://svn.apache.org/viewvc?rev=1026351&view=rev
Log:
SLING-1850 do not abort error handling early if the response has
already been committed. We must give the filters and error handlers
a chance to operate (assuming they know what to do if the response
has already been committed)

Modified:
    sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java

Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java?rev=1026351&r1=1026350&r2=1026351&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java (original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java Fri Oct 22 14:54:15 2010
@@ -319,14 +319,6 @@ public class SlingRequestProcessorImpl i
             final SlingHttpServletRequest request,
             SlingHttpServletResponse response) throws IOException {
 
-        // nothing to do but log the error if the response is committed
-        if (response.isCommitted()) {
-            log.error(
-                "handleError: Response already committed; cannot send error {}/{}",
-                new Object[] { status, message });
-            return;
-        }
-
         // wrap the response ensuring getWriter will fall back to wrapping
         // the response output stream if reset does not reset this
         response = new ErrorResponseWrapper(response);
@@ -359,14 +351,6 @@ public class SlingRequestProcessorImpl i
             final SlingHttpServletRequest request,
             SlingHttpServletResponse response) throws IOException {
 
-        // nothing to do but log the error if the response is committed
-        if (response.isCommitted()) {
-            log.error(
-                "handleError: Response already committed; cannot send error",
-                throwable);
-            return;
-        }
-
         // wrap the response ensuring getWriter will fall back to wrapping
         // the response output stream if reset does not reset this
         response = new ErrorResponseWrapper(response);
@@ -424,5 +408,17 @@ public class SlingRequestProcessorImpl i
             }
             return writer;
         }
+
+        /**
+         * Flush the writer if the {@link #getWriter()} method was called
+         * to potentially wrap an OuputStream still existing in the response.
+         */
+        @Override
+        public void flushBuffer() throws IOException {
+            if (writer != null) {
+                writer.flush();
+            }
+            super.flushBuffer();
+        }
     }
 }