Repository: camel Updated Branches: refs/heads/camel-2.13.x 40b308409 -> f9340dcaf
CAMEL-7448 updated Throttler to use previous maximumRequestsPerPeriod value if missing Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f9340dca Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f9340dca Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f9340dca Branch: refs/heads/camel-2.13.x Commit: f9340dcaf830f08cc2a0476402a081399553258c Parents: 40b3084 Author: boday <bo...@apache.org> Authored: Tue Aug 26 15:57:39 2014 -0700 Committer: boday <bo...@apache.org> Committed: Tue Aug 26 20:42:20 2014 -0700 ---------------------------------------------------------------------- .../org/apache/camel/processor/Throttler.java | 2 +- .../camel/processor/ThrottlerNullEvalTest.java | 26 +++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f9340dca/camel-core/src/main/java/org/apache/camel/processor/Throttler.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java index 6b51a2c..fb38495 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java +++ b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java @@ -105,7 +105,7 @@ public class Throttler extends DelayProcessorSupport implements Traceable { protected long calculateDelay(Exchange exchange) { // evaluate as Object first to see if we get any result at all Object result = maxRequestsPerPeriodExpression.evaluate(exchange, Object.class); - if (result == null) { + if (maximumRequestsPerPeriod == 0 && result == null) { throw new RuntimeExchangeException("The max requests per period expression was evaluated as null: " + maxRequestsPerPeriodExpression, exchange); } http://git-wip-us.apache.org/repos/asf/camel/blob/f9340dca/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java index a3db8ae..6205059 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java @@ -24,21 +24,41 @@ import org.apache.camel.builder.RouteBuilder; */ public class ThrottlerNullEvalTest extends ContextTestSupport { - public void testNullEvalTest() throws Exception { + public void testFirstNullEvalTest() throws Exception { getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Bye World"); getMockEndpoint("mock:dead").expectedBodiesReceived("Kaboom"); - template.sendBodyAndHeader("seda:a", "Hello World", "max", 2); template.sendBodyAndHeader("seda:a", "Kaboom", "max", null); + template.sendBodyAndHeader("seda:a", "Hello World", "max", 2); template.sendBodyAndHeader("seda:a", "Bye World", "max", 2); assertMockEndpointsSatisfied(); } - public void testNoHeaderTest() throws Exception { + public void testFirstNoHeaderTest() throws Exception { getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Bye World"); getMockEndpoint("mock:dead").expectedBodiesReceived("Kaboom"); + template.sendBody("seda:a", "Kaboom"); + template.sendBodyAndHeader("seda:a", "Hello World", "max", 2); + template.sendBodyAndHeader("seda:a", "Bye World", "max", 2); + + assertMockEndpointsSatisfied(); + } + + public void testNullEvalTest() throws Exception { + getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Kaboom", "Bye World"); + + template.sendBodyAndHeader("seda:a", "Hello World", "max", 2); + template.sendBodyAndHeader("seda:a", "Kaboom", "max", null); + template.sendBodyAndHeader("seda:a", "Bye World", "max", 2); + + assertMockEndpointsSatisfied(); + } + + public void testNoHeaderTest() throws Exception { + getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Kaboom", "Bye World"); + template.sendBodyAndHeader("seda:a", "Hello World", "max", 2); template.sendBody("seda:a", "Kaboom"); template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);