} catch (InterruptedException ignore) {}
}
}
if (!completed) {
OutputStream out = new ContentOutputStream(outputBuffer);
try {
if (msgContext.isPropertyTrue(NhttpConstants.FORCE_HTTP_1_0)) {
writeMessageFromTempData(out);
} else {
if (chunked) {
messageFormatter.writeTo(msgContext, format, out, false);
} else {
writeMessageFromTempData(out);
}
}
} catch (Exception e) {
Throwable t = e.getCause();
if (t != null && t.getCause() != null && t.getCause() instanceof ClosedChannelException) {
if (log.isDebugEnabled()) {
log.debug("Ignore closed channel exception, as the " +
"SessionRequestCallback handles this exception");
}
} else {
Integer errorCode = msgContext == null ? null :
(Integer) msgContext.getProperty(NhttpConstants.ERROR_CODE);
if (errorCode == null || errorCode == NhttpConstants.SEND_ABORT) {
if (log.isDebugEnabled()) {
log.debug("Remote server aborted request being sent, and responded");
}
} else {
if (e instanceof AxisFault) {
throw (AxisFault) e;
} else {
handleException("Error streaming message context", e);
}
}
}
}
finally {
try {
out.flush();
out.close();
} catch (IOException e) {
handleException("Error closing outgoing message stream", e);
}
setSendingCompleted(true);
}