You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/03/18 17:50:17 UTC

svn commit: r755644 - /servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java

Author: gnodet
Date: Wed Mar 18 16:50:17 2009
New Revision: 755644

URL: http://svn.apache.org/viewvc?rev=755644&view=rev
Log:
SMXCOMP-469: Terminated exchanges are sometimes sent when an handling an exception, leading to errors

Modified:
    servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java

Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=755644&r1=755643&r2=755644&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Wed Mar 18 16:50:17 2009
@@ -27,6 +27,7 @@
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.messaging.Fault;
 import javax.security.auth.Subject;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -205,21 +206,25 @@
             }
         }
         if (exchange.getStatus() == ExchangeStatus.ERROR) {
-            if (exchange.getError() != null) {
-                throw new Exception(exchange.getError());
-            } else {
-                throw new Exception("Unknown Error");
+            Exception e = exchange.getError();
+            if (e == null) {
+                e = new Exception("Unkown error (exchange aborted ?)");
             }
+            throw e;
         } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
             try {
-                if (exchange.getFault() != null) {
+                Fault fault = exchange.getFault();
+                if (fault != null) {
                     processFault(exchange, request, response);
                 } else {
                     processResponse(exchange, request, response);
                 }
-            } finally {
                 exchange.setStatus(ExchangeStatus.DONE);
                 channel.send(exchange);
+            } catch (Exception e) {
+                exchange.setError(e);
+                channel.send(exchange);
+                throw e;
             }
         } else if (exchange.getStatus() == ExchangeStatus.DONE) {
             // This happens when there is no response to send back