Fixing Camel hystrix issue:
https://issues.apache.org/jira/browse/CAMEL-11279

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/51da163c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/51da163c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/51da163c

Branch: refs/heads/camel-2.19.x
Commit: 51da163c6b2834858952f2f1d2fe833ffcce6f93
Parents: 398f14b
Author: Anton Krosnev <anton.kros...@ocado.com>
Authored: Sun May 14 16:21:43 2017 +0300
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue May 16 12:28:40 2017 +0200

----------------------------------------------------------------------
 .../processor/HystrixProcessorCommand.java      | 22 +++++++++-----------
 1 file changed, 10 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/51da163c/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorCommand.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorCommand.java
 
b/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorCommand.java
index 511a46e..ab3b696 100644
--- 
a/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorCommand.java
+++ 
b/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorCommand.java
@@ -124,7 +124,8 @@ public class HystrixProcessorCommand extends HystrixCommand 
{
         }
 
         // remember any hystrix execution exception which for example can be 
triggered by a hystrix timeout
-        Throwable cause = getExecutionException();
+        Throwable hystrixExecutionException = getExecutionException();
+        Exception camelExchangeException = copy.getException();
 
         synchronized (lock) {
 
@@ -143,20 +144,17 @@ public class HystrixProcessorCommand extends 
HystrixCommand {
 
             // execution exception must take precedence over exchange exception
             // because hystrix may have caused this command to fail due 
timeout or something else
-            if (cause != null) {
-                exchange.setException(new CamelExchangeException("Hystrix 
execution exception occurred while processing Exchange", exchange, cause));
+            if (hystrixExecutionException != null) {
+                exchange.setException(new CamelExchangeException("Hystrix 
execution exception occurred while processing Exchange", exchange, 
hystrixExecutionException));
             }
 
-            // if we have a fallback that can process the exchange in case of 
an exception
-            // then we need to trigger this by throwing an exception so 
Hystrix will execute the fallback
-            // if we don't have a fallback and an exception was thrown then 
its stored on the exchange
-            // and Camel will detect the exception anyway
-            if (fallback != null || fallbackCommand != null) {
-                if (fallbackEnabled == null || fallbackEnabled && 
exchange.getException() != null) {
-                    // throwing exception will cause hystrix to execute 
fallback
-                    throw exchange.getException();
-                }
+            // in case of an exception in the exchange
+            // we need to trigger this by throwing the exception so Hystrix 
will execute the fallback
+            // or open the circuit
+            if (hystrixExecutionException == null && camelExchangeException != 
null) {
+                throw camelExchangeException;
             }
+            //}
 
             LOG.debug("Running processor: {} with exchange: {} done", 
processor, exchange);
             return exchange.hasOut() ? exchange.getOut() : exchange.getIn();

Reply via email to