You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/05/20 06:59:03 UTC

[camel] branch master updated (7b2f54a -> 34eeb10)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 7b2f54a  Add first version to pulsar
     new 6504667  CAMEL-13541: fixed Race condition in camel-hystrix when xecutionTimeoutInMilliseconds() and onFallback() are used
     new 34eeb10  CAMEL-13541 - Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../component/hystrix/processor/HystrixProcessorCommand.java   | 10 +++++++++-
 .../camel/component/hystrix/processor/HystrixTimeoutTest.java  |  4 ++--
 .../hystrix/processor/HystrixTimeoutWithFallbackTest.java      |  9 ++++++---
 3 files changed, 17 insertions(+), 6 deletions(-)


[camel] 01/02: CAMEL-13541: fixed Race condition in camel-hystrix when xecutionTimeoutInMilliseconds() and onFallback() are used

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 650466734eedbeb61cbb4e98a6c269ab4e541d1e
Author: Andrea Tarocchi <at...@redhat.com>
AuthorDate: Fri May 17 22:32:09 2019 +0200

    CAMEL-13541: fixed Race condition in camel-hystrix when xecutionTimeoutInMilliseconds() and onFallback() are used
---
 .../component/hystrix/processor/HystrixProcessorCommand.java   | 10 +++++++++-
 .../camel/component/hystrix/processor/HystrixTimeoutTest.java  |  4 ++--
 .../hystrix/processor/HystrixTimeoutWithFallbackTest.java      |  9 ++++++---
 3 files changed, 17 insertions(+), 6 deletions(-)

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 e8aa26c..94289ff 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
@@ -117,6 +117,15 @@ public class HystrixProcessorCommand extends HystrixCommand {
             copy.setException(e);
         }
 
+        // if hystrix execution timeout is enabled and fallback is enabled and a timeout occurs
+        // then a hystrix timer thread executes the fallback so we can stop run() execution
+        if(getProperties().executionTimeoutEnabled().get()
+                && getProperties().fallbackEnabled().get()
+                && isCommandTimedOut.get() == TimedOutStatus.TIMED_OUT) {
+            LOG.debug("Exiting run command due to a hystrix execution timeout in processing exchange: {}", exchange);
+            return null;
+        }
+
         // when a hystrix timeout occurs then a hystrix timer thread executes the fallback
         // and therefore we need this thread to not do anymore if fallback is already in process
         if (fallbackInUse.get()) {
@@ -129,7 +138,6 @@ public class HystrixProcessorCommand extends HystrixCommand {
         Exception camelExchangeException = copy.getException();
 
         synchronized (lock) {
-
             // when a hystrix timeout occurs then a hystrix timer thread executes the fallback
             // and therefore we need this thread to not do anymore if fallback is already in process
             if (fallbackInUse.get()) {
diff --git a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutTest.java b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutTest.java
index d0ebdb6..7e78057 100644
--- a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutTest.java
+++ b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutTest.java
@@ -40,7 +40,7 @@ public class HystrixTimeoutTest extends CamelTestSupport {
         // this calls the slow route and therefore causes a timeout which triggers an exception
         try {
             template.requestBody("direct:start", "slow");
-            fail("Should fail due timeout");
+            fail("Should fail due to timeout");
         } catch (Exception e) {
             // expected a timeout
             assertIsInstanceOf(TimeoutException.class, e.getCause().getCause());
@@ -54,7 +54,7 @@ public class HystrixTimeoutTest extends CamelTestSupport {
             try {
                 log.info(">>> test run " + i + " <<<");
                 template.requestBody("direct:start", "slow");
-                fail("Should fail due timeout");
+                fail("Should fail due to timeout");
             } catch (Exception e) {
                 // expected a timeout
                 assertIsInstanceOf(TimeoutException.class, e.getCause().getCause());
diff --git a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutWithFallbackTest.java b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutWithFallbackTest.java
index ee9ebe9..dfaae57 100644
--- a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutWithFallbackTest.java
+++ b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixTimeoutWithFallbackTest.java
@@ -30,14 +30,14 @@ public class HystrixTimeoutWithFallbackTest extends CamelTestSupport {
     public void testFast() throws Exception {
         // this calls the fast route and therefore we get a response
         Object out = template.requestBody("direct:start", "fast");
-        assertEquals("Fast response", out);
+        assertEquals("LAST CHANGE", out);
     }
 
     @Test
     public void testSlow() throws Exception {
         // this calls the slow route and therefore causes a timeout which triggers the fallback
         Object out = template.requestBody("direct:start", "slow");
-        assertEquals("Fallback response", out);
+        assertEquals("LAST CHANGE", out);
     }
 
     @Override
@@ -58,7 +58,10 @@ public class HystrixTimeoutWithFallbackTest extends CamelTestSupport {
                         .transform().constant("Fallback response")
                         .log("Hystrix fallback end: ${threadName}")
                     .end()
-                    .log("After Hystrix ${body}");
+                    .log("After Hystrix ${body}")
+                    .transform(simple("A CHANGE"))
+                    .transform(simple("LAST CHANGE"))
+                    .log("End ${body}");
 
                 from("direct:fast")
                     // this is a fast route and takes 1 second to respond


[camel] 02/02: CAMEL-13541 - Fixed CS

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 34eeb10d1a4e12cc20b20ddda471043e777d42a4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon May 20 08:58:39 2019 +0200

    CAMEL-13541 - Fixed CS
---
 .../camel/component/hystrix/processor/HystrixProcessorCommand.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 94289ff..efa9c9b 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
@@ -119,7 +119,7 @@ public class HystrixProcessorCommand extends HystrixCommand {
 
         // if hystrix execution timeout is enabled and fallback is enabled and a timeout occurs
         // then a hystrix timer thread executes the fallback so we can stop run() execution
-        if(getProperties().executionTimeoutEnabled().get()
+        if (getProperties().executionTimeoutEnabled().get()
                 && getProperties().fallbackEnabled().get()
                 && isCommandTimedOut.get() == TimedOutStatus.TIMED_OUT) {
             LOG.debug("Exiting run command due to a hystrix execution timeout in processing exchange: {}", exchange);