Repository: camel Updated Branches: refs/heads/master 61839f228 -> 76ddb85f5
CAMEL-7504: Have a ThrottlerRejectedExecutionException instead of a generic RejectedExecutionException Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e7eddb02 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e7eddb02 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e7eddb02 Branch: refs/heads/master Commit: e7eddb02286cd8f147324462d6e15b8f09dec1df Parents: 9d661ab Author: david <da...@davidkarlsen.com> Authored: Wed Jul 2 20:29:59 2014 +0200 Committer: david <da...@davidkarlsen.com> Committed: Wed Jul 2 20:29:59 2014 +0200 ---------------------------------------------------------------------- .../org/apache/camel/model/ThrottleDefinition.java | 2 +- .../java/org/apache/camel/processor/Throttler.java | 16 +++++----------- .../ThrottlerRejectedExecutionException.java | 15 +++++++++++++++ .../org/apache/camel/processor/ThrottlerTest.java | 10 +++++----- .../org/apache/camel/spring/processor/throttler.xml | 2 +- 5 files changed, 27 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e7eddb02/camel-core/src/main/java/org/apache/camel/model/ThrottleDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ThrottleDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ThrottleDefinition.java index b829052..9ec13f8 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ThrottleDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/ThrottleDefinition.java @@ -168,7 +168,7 @@ public class ThrottleDefinition extends ExpressionNode implements ExecutorServic } /** - * Whether or not throttler throws the RejectExceutionException when the exchange exceeds the request limit + * Whether or not throttler throws the ThrottlerRejectedExecutionException when the exchange exceeds the request limit * <p/> * Is by default <tt>false</tt> * http://git-wip-us.apache.org/repos/asf/camel/blob/e7eddb02/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 a48f6a5..f1dcfce 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 @@ -16,19 +16,13 @@ */ package org.apache.camel.processor; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.atomic.AtomicLong; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.Expression; -import org.apache.camel.Processor; -import org.apache.camel.RuntimeExchangeException; +import org.apache.camel.*; import org.apache.camel.Traceable; import org.apache.camel.util.ObjectHelper; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicLong; + /** * A <a href="http://camel.apache.org/throttler.html">Throttler</a> * will set a limit on the maximum number of message exchanges which can be sent @@ -212,7 +206,7 @@ public class Throttler extends DelayProcessorSupport implements Traceable { @Override protected boolean processDelay(Exchange exchange, AsyncCallback callback, long delay) { if (isRejectExecution() && delay > 0) { - exchange.setException(new RejectedExecutionException("Exceed the max request limit!")); + exchange.setException(new ThrottlerRejectedExecutionException("Exceed the max request limit!")); callback.done(true); return true; } else { http://git-wip-us.apache.org/repos/asf/camel/blob/e7eddb02/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java b/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java new file mode 100644 index 0000000..6790760 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java @@ -0,0 +1,15 @@ +package org.apache.camel.processor; + +import java.util.concurrent.RejectedExecutionException; + +/** + * Created by david on 02/07/14. + */ +public class ThrottlerRejectedExecutionException + extends RejectedExecutionException +{ + public ThrottlerRejectedExecutionException(String message) { + super(message); + } +} + http://git-wip-us.apache.org/repos/asf/camel/blob/e7eddb02/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java index c1ffbc1..f18631a 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java @@ -16,15 +16,15 @@ */ package org.apache.camel.processor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionException; - import org.apache.camel.ContextTestSupport; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.DefaultExchange; import org.apache.camel.processor.Throttler.TimeSlot; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + import static org.apache.camel.builder.Builder.constant; /** @@ -222,7 +222,7 @@ public class ThrottlerTest extends ContextTestSupport { return new RouteBuilder() { public void configure() { - onException(RejectedExecutionException.class) + onException(ThrottlerRejectedExecutionException.class) .handled(true) .to("mock:error"); http://git-wip-us.apache.org/repos/asf/camel/blob/e7eddb02/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml index 157db1a..11f8791 100644 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml @@ -24,7 +24,7 @@ <camelContext xmlns="http://camel.apache.org/schema/spring"> <onException> - <exception>java.util.concurrent.RejectedExecutionException</exception> + <exception>org.apache.camel.processor.ThrottlerRejectedExecutionException</exception> <handled><constant>true</constant></handled> <to uri="mock:error"/> </onException>