You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bo...@apache.org on 2014/08/27 01:09:55 UTC

git commit: CAMEL-7448 updated Throttler to use previous maximumRequestsPerPeriod value if missing

Repository: camel
Updated Branches:
  refs/heads/master d0a36fe12 -> 35bde2b29


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/35bde2b2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/35bde2b2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/35bde2b2

Branch: refs/heads/master
Commit: 35bde2b29f616d2f3b51e81b805b4ea635d228c9
Parents: d0a36fe
Author: boday <bo...@apache.org>
Authored: Tue Aug 26 15:57:39 2014 -0700
Committer: boday <bo...@apache.org>
Committed: Tue Aug 26 15:57:39 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/35bde2b2/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 f70325d..c986bf7 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
@@ -108,7 +108,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/35bde2b2/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);