Fix for SYNAPSE-1048 by Isuru Ranawaka
git-svn-id: https://svn.apache.org/repos/asf/synapse/trunk@1860309 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java b/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java
index 683c2b4..0758c85 100644
--- a/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java
+++ b/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java
@@ -477,13 +477,24 @@
}
public void exception(NHttpClientConnection conn, Exception e) {
+ ProtocolState state = TargetContext.getState(conn);
+
+ if (state == ProtocolState.REQUEST_HEAD || state == ProtocolState.REQUEST_BODY) {
+ informWriterError(conn);
+ log.warn("Exception occurred while writing the request data");
+ } else if (state == ProtocolState.RESPONSE_HEAD || state == ProtocolState.RESPONSE_BODY) {
+ informReaderError(conn);
+ log.warn("Exception occurred while reading the response data");
+ } else if (state == ProtocolState.REQUEST_DONE) {
+ log.warn("Exception occurred after writing the request data but before reading the response data");
+ }
+
if (e instanceof HttpException) {
exception(conn, (HttpException) e);
} else if (e instanceof IOException) {
exception(conn, (IOException) e);
} else {
log.error("Unexpected exception encountered in TargetHandler", e);
- ProtocolState state = TargetContext.getState(conn);
MessageContext requestMsgCtx = TargetContext.get(conn).getRequestMsgCtx();
if (requestMsgCtx != null) {
targetErrorHandler.handleError(requestMsgCtx,