Repository: camel Updated Branches: refs/heads/master 3dc47cc6c -> 9b18b1241
camel-hystrix: Ensure configuration is not lost when setting other parameters separately. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9b18b124 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9b18b124 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9b18b124 Branch: refs/heads/master Commit: 9b18b12419c8a7378a7589262cf34347378f2f95 Parents: 3dc47cc Author: Raúl Kripalani <ra...@apache.org> Authored: Mon Jul 25 13:49:58 2016 +0100 Committer: Raúl Kripalani <ra...@apache.org> Committed: Wed Aug 17 23:32:51 2016 +0100 ---------------------------------------------------------------------- .../apache/camel/model/HystrixDefinition.java | 4 +-- .../processor/HystrixRouteConfigTest.java | 33 +++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9b18b124/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java b/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java index 7ef7302..901c1ab 100644 --- a/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java @@ -173,10 +173,10 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition> { * Use <tt>end</tt> when configuration is complete, to return back to the Hystrix EIP. */ public HystrixConfigurationDefinition hystrixConfiguration() { - hystrixConfiguration = new HystrixConfigurationDefinition(this); + hystrixConfiguration = hystrixConfiguration == null ? new HystrixConfigurationDefinition(this) : hystrixConfiguration; return hystrixConfiguration; } - + /** * Configures the Hystrix EIP using the given configuration */ http://git-wip-us.apache.org/repos/asf/camel/blob/9b18b124/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java index cf0b164..b9bfc1c 100644 --- a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java +++ b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java @@ -17,6 +17,9 @@ package org.apache.camel.component.hystrix.processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.HystrixConfigurationDefinition; +import org.apache.camel.model.HystrixDefinition; +import org.apache.camel.model.RouteDefinition; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; @@ -30,7 +33,35 @@ public class HystrixRouteConfigTest extends CamelTestSupport { assertMockEndpointsSatisfied(); } - + + @Test + public void testGroupKeyAndThreadPoolKeyConfigFlagsDoNotScrapHystrixConfiguration() throws Exception { + // dummy route + RouteBuilder rb = new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:foo") + .hystrix() + .hystrixConfiguration().groupKey("test1").metricsHealthSnapshotIntervalInMilliseconds(99999).end() + .groupKey("test2") + // ^^^ should only override the groupKey from the HystrixConfigurationDefinition; + // it should not discard the full HystrixConfigurationDefinition. + .to("log:hello") + .end(); + + } + }; + + rb.configure(); + + RouteDefinition route = rb.getRouteCollection().getRoutes().get(0); + assertEquals(HystrixDefinition.class, route.getOutputs().get(0).getClass()); + + HystrixConfigurationDefinition config = ((HystrixDefinition) route.getOutputs().get(0)).getHystrixConfiguration(); + assertEquals("test2", config.getGroupKey()); + assertEquals(99999, config.getMetricsHealthSnapshotIntervalInMilliseconds().intValue()); + } + @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() {