You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/11/01 11:25:36 UTC

[1/2] camel git commit: CAMEL-10430: camel-hystrix - Should also execute fallback if exception not from Camel

Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 3a7d6f37f -> 31f1b4eb8
  refs/heads/master edb1b2a18 -> 23f63cb09


CAMEL-10430: camel-hystrix - Should also execute fallback if exception not from Camel


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

Branch: refs/heads/master
Commit: 23f63cb099e19aa1e2e1cf7ec070997cef18cd73
Parents: edb1b2a
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Nov 1 12:24:59 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Nov 1 12:24:59 2016 +0100

----------------------------------------------------------------------
 .../hystrix/processor/HystrixProcessorCommand.java     | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/23f63cb0/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 cbd6254..07157a5 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
@@ -45,14 +45,15 @@ public class HystrixProcessorCommand extends HystrixCommand {
 
     @Override
     protected Message getFallback() {
-        // only run fallback if there was an exception
-        Exception exception = exchange.getException();
-        if (exception == null) {
-            return exchange.hasOut() ? exchange.getOut() : exchange.getIn();
-        }
+        // grab the exception that caused the error (can be failure in run, or from hystrix if short circuited)
+        Throwable exception = getExecutionException();
 
         if (fallback != null || fallbackCommand != null) {
-            LOG.debug("Error occurred processing. Will now run fallback. Exception class: {} message: {}.", exception.getClass().getName(), exception.getMessage());
+            if (exception != null) {
+                LOG.debug("Error occurred processing. Will now run fallback. Exception class: {} message: {}.", exception.getClass().getName(), exception.getMessage());
+            } else {
+                LOG.debug("Error occurred processing. Will now run fallback.");
+            }
             // store the last to endpoint as the failure endpoint
             if (exchange.getProperty(Exchange.FAILURE_ENDPOINT) == null) {
                 exchange.setProperty(Exchange.FAILURE_ENDPOINT, exchange.getProperty(Exchange.TO_ENDPOINT));


[2/2] camel git commit: CAMEL-10430: camel-hystrix - Should also execute fallback if exception not from Camel

Posted by da...@apache.org.
CAMEL-10430: camel-hystrix - Should also execute fallback if exception not from Camel


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

Branch: refs/heads/camel-2.18.x
Commit: 31f1b4eb8f1bef7bdf06705f2e397ba272d09594
Parents: 3a7d6f3
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Nov 1 12:24:59 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Nov 1 12:25:28 2016 +0100

----------------------------------------------------------------------
 .../hystrix/processor/HystrixProcessorCommand.java     | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/31f1b4eb/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 cbd6254..07157a5 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
@@ -45,14 +45,15 @@ public class HystrixProcessorCommand extends HystrixCommand {
 
     @Override
     protected Message getFallback() {
-        // only run fallback if there was an exception
-        Exception exception = exchange.getException();
-        if (exception == null) {
-            return exchange.hasOut() ? exchange.getOut() : exchange.getIn();
-        }
+        // grab the exception that caused the error (can be failure in run, or from hystrix if short circuited)
+        Throwable exception = getExecutionException();
 
         if (fallback != null || fallbackCommand != null) {
-            LOG.debug("Error occurred processing. Will now run fallback. Exception class: {} message: {}.", exception.getClass().getName(), exception.getMessage());
+            if (exception != null) {
+                LOG.debug("Error occurred processing. Will now run fallback. Exception class: {} message: {}.", exception.getClass().getName(), exception.getMessage());
+            } else {
+                LOG.debug("Error occurred processing. Will now run fallback.");
+            }
             // store the last to endpoint as the failure endpoint
             if (exchange.getProperty(Exchange.FAILURE_ENDPOINT) == null) {
                 exchange.setProperty(Exchange.FAILURE_ENDPOINT, exchange.getProperty(Exchange.TO_ENDPOINT));