SMXCOMP-965 - HttpConsumerEndpoint invokes sendError with null exchange
git-svn-id: https://svn.apache.org/repos/asf/servicemix/components/trunk@1442965 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java b/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
index 0cb9813..f4b1508 100644
--- a/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
+++ b/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
@@ -330,11 +330,12 @@
* (either because the exchange was received or because the request timed out)
*/
public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
- MessageExchange exchange;
+ MessageExchange exchange = null;
Continuation continuation = null;
Object mutex = null;
String id = null;
-
+ boolean wasCleaned = false;
+
try {
// Handle WSDLs, XSDs
if (handleStaticResource(request, response)) {
@@ -392,9 +393,13 @@
// message exchange has been completed, so we're ready to send back an HTTP response now
logger.debug("Resuming HTTP request: {}", request);
doClean(mutex, continuation, id);
+ wasCleaned = true;
handleResponse(exchange, request, response);
} catch (Exception e) {
- sendError(doClean(mutex, continuation, id), e, request, response);
+ if (!wasCleaned) {
+ exchange = doClean(mutex, continuation, id);
+ }
+ sendError(exchange, e, request, response);
}
}