From 9e3ff03f737904a6f46f0ae9c168e9fd918cc200 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 7 Jun 2011 14:00:16 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51324 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 | 20 ++++++++++++-------- webapps/docs/changelog.xml | 9 +++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/java/org/apache/catalina/connector/OutputBuffer.java b/java/org/apache/catalina/connector/OutputBuffer.java index d58bfd534..f3d59efa8 100644 --- a/java/org/apache/catalina/connector/OutputBuffer.java +++ b/java/org/apache/catalina/connector/OutputBuffer.java @@ -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, diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index b260dc0fd..786fa8b55 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -43,6 +43,15 @@ Other -->
+ + + + 51324: 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) + + + -- 2.11.0