Blocking ISE
@@ -648,9 +648,9 @@ public abstract class AbstractHTTPDestination
if (hasNoResponseContent(outMessage)) {
response.setContentLength(0);
response.flushBuffer();
- response.getOutputStream().close();
+ closeResponseOutputStream(response);
} else if (!getStream) {
- response.getOutputStream().close();
+ closeResponseOutputStream(response);
} else {
responseStream = response.getOutputStream();
}
@@ -661,6 +661,14 @@ public abstract class AbstractHTTPDestination
return responseStream;
}
+ private void closeResponseOutputStream(HttpServletResponse response) throws IOException {
+ try {
+ response.getOutputStream().close();
+ } catch (IllegalStateException ex) {
+ // response.getWriter() has already been called
+ }
+ }
+
private int getReponseCodeFromMessage(Message message) {
Integer i = (Integer)message.get(Message.RESPONSE_CODE);
if (i != null) {
