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 <davscl...@apache.org> Authored: Tue Nov 1 12:24:59 2016 +0100 Committer: Claus Ibsen <davscl...@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));