camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] camel git commit: CAMEL-10662: camel-hystrix - If hystrix timeout occurs then the hystrix timeout exception should be cause
Date Thu, 29 Dec 2016 16:55:30 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 36e481749 -> abc319031
  refs/heads/master 28dcd4340 -> 906a612d3


CAMEL-10662: camel-hystrix - If hystrix timeout occurs then the hystrix timeout exception
should be cause


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

Branch: refs/heads/camel-2.18.x
Commit: 2b5ba0bfb33b3f1475cf79cb2be569725ef15d3c
Parents: 36e4817
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Dec 29 14:16:59 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Dec 29 14:17:24 2016 +0100

----------------------------------------------------------------------
 .../hystrix/processor/HystrixProcessorCommand.java  | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2b5ba0bf/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 4face6e..4d86ef7 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
@@ -17,6 +17,7 @@
 package org.apache.camel.component.hystrix.processor;
 
 import com.netflix.hystrix.HystrixCommand;
+import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
@@ -45,10 +46,10 @@ public class HystrixProcessorCommand extends HystrixCommand {
 
     @Override
     protected Message getFallback() {
-        // 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) {
+            // grab the exception that caused the error (can be failure in run, or from hystrix
if short circuited)
+            Throwable exception = getExecutionException();
+
             if (exception != null) {
                 LOG.debug("Error occurred processing. Will now run fallback. Exception class:
{} message: {}.", exception.getClass().getName(), exception.getMessage());
             } else {
@@ -100,13 +101,20 @@ public class HystrixProcessorCommand extends HystrixCommand {
         // is fallback enabled
         Boolean fallbackEnabled = getProperties().fallbackEnabled().get();
 
+        // execution exception must take precedence over exchange exception
+        // because hystrix may have caused this command to fail due timeout or something
else
+        Throwable exception = getExecutionException();
+        if (exception != null) {
+            exchange.setException(new CamelExchangeException("Hystrix execution exception
occurred while processing Exchange", exchange, exception));
+        }
+
         // if we failed then throw an exception if fallback is enabled
         if (fallbackEnabled == null || fallbackEnabled && exchange.getException()
!= null) {
             throw exchange.getException();
         }
 
-        LOG.debug("Running processor: {} with exchange: {} done", processor, exchange);
         // no fallback then we are done
+        LOG.debug("Running processor: {} with exchange: {} done", processor, exchange);
         return exchange.hasOut() ? exchange.getOut() : exchange.getIn();
     }
 }


Mime
View raw message