Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51324
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 7 Jun 2011 14:00:16 +0000 (14:00 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 7 Jun 2011 14:00:16 +0000 (14:00 +0000)
Improve handling of exceptions when flushing the response buffer to ensure that the doFlush flag does not get stuck in the enabled state.
Patch provided by Jeremy Norris.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1133014 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/OutputBuffer.java
webapps/docs/changelog.xml

index d58bfd5..f3d59ef 100644 (file)
@@ -228,6 +228,7 @@ public class OutputBuffer extends Writer
         
         bb.recycle(); 
         closed = false;
+        doFlush = false;
         suspended = false;
         
         if (conv!= null) {
@@ -310,15 +311,18 @@ public class OutputBuffer extends Writer
         if (suspended)
             return;
 
-        doFlush = true;
-        if (initial) {
-            coyoteResponse.sendHeaders();
-            initial = false;
-        }
-        if (bb.getLength() > 0) {
-            bb.flushBuffer();
+        try {
+            doFlush = true;
+            if (initial) {
+                coyoteResponse.sendHeaders();
+                initial = false;
+            }
+            if (bb.getLength() > 0) {
+                bb.flushBuffer();
+            }
+        } finally {
+            doFlush = false;
         }
-        doFlush = false;
 
         if (realFlush) {
             coyoteResponse.action(ActionCode.CLIENT_FLUSH, 
index b260dc0..786fa8b 100644 (file)
   Other
 -->
 <section name="Tomcat 7.0.16 (markt)">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        <bug>51324</bug>: Improve handling of exceptions when flushing the
+        response buffer to ensure that the doFlush flag does not get stuck in
+        the enabled state. Patch provided by Jeremy Norris. (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Coyote">
     <changelog>
       <fix>