You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/05/15 09:03:45 UTC
[camel] branch 13514 created (now 2263832)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git.
at 2263832 CAMEL-13514: Add to migration guide
This branch includes the following new commits:
new 2f5df13 CAMEL-13501: Component should move initialization logic to doInit instead of doStart
new 31ef818 CAMEL-13501: Component should move initialization logic to doInit instead of doStart
new 414fd412 CAMEL-13514: Service API should not use checked exceptions in start/stop methods.
new ee798e1 CAMEL-13514: Service API should not use checked exceptions in start/stop methods.
new fb35c82 CAMEL-13514: Service API should not use checked exceptions in start/stop methods.
new 4d6ecba CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
new 8ae96e7 CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
new 47447ba CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
new e63e032 CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
new 9394829 CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
new 2263832 CAMEL-13514: Add to migration guide
The 11 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.
[camel] 11/11: CAMEL-13514: Add to migration guide
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 226383298aca5fb798effcce99173a78ab4935b0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed May 15 11:03:19 2019 +0200
CAMEL-13514: Add to migration guide
---
MIGRATION.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/MIGRATION.md b/MIGRATION.md
index 4c377b8..74886a7 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -186,9 +186,6 @@ The functionality to change the simple language tokens for start/end functions h
The following API changes may affect your existing Camel applications, which needs to be migrated.
-TODO: Should this be a table?
-TODO: Add the other moved classes/packages etc
-
#### CamelContext
The methods on `CamelContext` that are related to catalog has been moved into a new `CatalogCamelContext` interface, which you can access by adapting:
@@ -197,6 +194,11 @@ The methods on `CamelContext` that are related to catalog has been moved into a
The `loadRouteDefinitions` and `loadRestDefinitions` on `ModelCamelContext` has been changed to `addRouteDefinitions` and `addRestDefinitions` to be aligned with the other methods. You can find loader methods on the `ModelHelper` utility class.
+#### Checked vs unchecked exceptions
+
+Most of the Camel exception classes has been migrated to be unchecked (eg extends `RuntimeException`).
+
+Also the lifecycle of the `start`, `stop` and `suspend`, `resume` methods on `Service` and `SuspendableService` has been changed to not throw checked exceptions.
#### Generic Information
[camel] 05/11: CAMEL-13514: Service API should not use checked
exceptions in start/stop methods.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit fb35c828c71cb4b71ed8a56cec820c8c17bd9f37
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 12:00:29 2019 +0200
CAMEL-13514: Service API should not use checked exceptions in start/stop methods.
---
components/readme.adoc | 2 +-
.../springboot/test/support/ReactiveStreamsServiceTestSupport.java | 4 ++--
.../org/apache/camel/itest/idempotent/JdbcIdempotentRepository.java | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/components/readme.adoc b/components/readme.adoc
index 927e597..b24e55f 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -463,7 +463,7 @@ Number of Components: 295 in 232 JAR artifacts (0 deprecated)
| link:camel-jing/src/main/docs/jing-component.adoc[Jing] (camel-jing) +
`jing:resourceUri` | 1.1 | Validates the payload of a message using RelaxNG Syntax using Jing library.
-| link:camel-jms/src/main/docs/jms-component.adoc[JMS] (camel-jms) +
+| link:@@@ARTIFACTID@@@/src/main/docs/jms-component.adoc[JMS] (@@@ARTIFACTID@@@) +
`jms:destinationType:destinationName` | 1.0 | The jms component allows messages to be sent to (or consumed from) a JMS Queue or Topic.
| link:camel-jmx/src/main/docs/jmx-component.adoc[JMX] (camel-jmx) +
diff --git a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java
index 41133aa..7341c08 100644
--- a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java
+++ b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java
@@ -150,12 +150,12 @@ public class ReactiveStreamsServiceTestSupport implements CamelReactiveStreamsSe
}
@Override
- public void start() throws Exception {
+ public void start() {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
}
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/idempotent/JdbcIdempotentRepository.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/idempotent/JdbcIdempotentRepository.java
index 17d3727..02e7535 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/idempotent/JdbcIdempotentRepository.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/idempotent/JdbcIdempotentRepository.java
@@ -57,11 +57,11 @@ public class JdbcIdempotentRepository implements IdempotentRepository {
jdbc.update("DELETE * FROM ProcessedPayments");
}
- public void start() throws Exception {
+ public void start() {
// noop
}
- public void stop() throws Exception {
+ public void stop() {
// noop
}
}
[camel] 04/11: CAMEL-13514: Service API should not use checked
exceptions in start/stop methods.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ee798e1ff070f909abea101d0f123affb2a65233
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 11:48:45 2019 +0200
CAMEL-13514: Service API should not use checked exceptions in start/stop methods.
---
.../apache/camel/blueprint/BlueprintCamelContext.java | 4 ++--
.../org/apache/camel/cdi/test/EventComponentTest.java | 4 ++--
.../camel/cdi/test/UnstoppedCamelContextBeanTest.java | 2 +-
.../component/cxf/CxfMultipleConsumersSupportTest.java | 3 +--
.../apache/camel/language/groovy/GroovyLanguage.java | 4 ++--
.../HttpsTwoDifferentSslContextParametersGetTest.java | 2 +-
.../CamelJaxbNoNamespaceSchemaLocationSpringTest.java | 4 ++--
.../java/org/apache/camel/jaxb/CamelJaxbSpringTest.java | 4 ++--
.../org/apache/camel/component/jms/JmsEndpoint.java | 4 ++--
.../camel/component/jt400/Jt400DataQueueService.java | 11 ++++++++---
.../KafkaConsumerRebalancePartitionRevokeTest.java | 4 ++--
.../component/kafka/KafkaConsumerRebalanceTest.java | 4 ++--
.../cluster/lock/KubernetesLeadershipController.java | 4 ++--
.../kubernetes/cluster/lock/TimedLeaderNotifier.java | 10 +++++++---
.../camel/component/lucene/LuceneIndexProducer.java | 7 ++-----
.../camel/component/lucene/LuceneQueryProducer.java | 6 ++++--
.../netty4/http/HttpServerBootstrapFactory.java | 2 +-
.../camel/component/quartz2/QuartzPropertiesTest.java | 5 ++---
.../streams/support/ReactiveStreamsTestService.java | 4 ++--
.../restlet/RestRestletCustomDataFormatInvalidTest.java | 3 +--
.../camel/component/salesforce/SalesforceComponent.java | 7 ++-----
.../salesforce/internal/SalesforceSession.java | 17 +++++++++++++----
.../salesforce/internal/client/AbstractClientBase.java | 10 +++++++---
.../internal/processor/AbstractRestProcessor.java | 4 ++--
.../internal/processor/AnalyticsApiProcessor.java | 4 ++--
.../salesforce/internal/processor/BulkApiProcessor.java | 4 ++--
.../internal/processor/CompositeApiProcessor.java | 4 ++--
.../org/apache/camel/component/seda/SedaEndpoint.java | 4 ++--
.../org/apache/camel/language/spel/SpelLanguage.java | 4 ++--
.../processor/JavaDslTransactedNoTXManagerTest.java | 3 +--
.../apache/camel/spring/processor/SpringTestHelper.java | 4 ++--
.../camel/component/webhook/MultiRestConsumer.java | 4 ++--
.../camel/component/websocket/MemoryWebsocketStore.java | 4 ++--
.../xstream/SpringMarshalDomainObjectJSONTest.java | 4 ++--
.../camel/dataformat/xstream/SpringMarshalListTest.java | 4 ++--
.../dataformat/xstream/SpringMarshalOmitFieldsTest.java | 4 ++--
.../xstream/SpringXStreamConfigurationTest.java | 4 ++--
37 files changed, 97 insertions(+), 83 deletions(-)
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
index 51b6193..f5827f2 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
@@ -105,7 +105,7 @@ public class BlueprintCamelContext extends DefaultCamelContext implements Servic
this.bundleStateService = bundleStateService;
}
- public void doInit() {
+ public void doInit() throws Exception {
log.trace("init {}", this);
// add service listener so we can be notified when blueprint container is done
// and we would be ready to start CamelContext
@@ -234,7 +234,7 @@ public class BlueprintCamelContext extends DefaultCamelContext implements Servic
}
@Override
- public void start() throws Exception {
+ public void start() {
final ClassLoader original = Thread.currentThread().getContextClassLoader();
try {
// let's set a more suitable TCCL while starting the context
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.java
index 39452b9..ba766eb 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.java
@@ -78,11 +78,11 @@ public class EventComponentTest {
static class NotStartedCamelContext extends DefaultCamelContext {
@Override
- public void start() throws Exception {
+ public void start() {
start(false);
}
- void start(boolean start) throws Exception {
+ void start(boolean start) {
if (start) {
super.start();
}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java
index 66098ce..d0ac9248 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java
@@ -80,7 +80,7 @@ class UnstoppedCamelContext extends DefaultCamelContext {
static boolean isStopCalled;
@Override
- public void stop() throws Exception {
+ public void stop() {
super.stop();
isStopCalled = true;
}
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java
index 418a599..7b812ce 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.cxf;
-import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
@@ -49,7 +48,7 @@ public class CxfMultipleConsumersSupportTest extends CamelTestSupport {
try {
context.start();
fail("Should have thrown an exception");
- } catch (FailedToStartRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getMessage().endsWith(
"Multiple consumers for the same endpoint is not allowed: cxf://http://localhost:" + port1
+ "/CxfMultipleConsumersSupportTest/test?serviceClass=org.apache.camel.component.cxf.HelloService"));
diff --git a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyLanguage.java b/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyLanguage.java
index da89ec4..2d7ed0c 100644
--- a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyLanguage.java
+++ b/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyLanguage.java
@@ -40,11 +40,11 @@ public class GroovyLanguage extends LanguageSupport {
}
@Override
- public void start() throws Exception {
+ public void start() {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
InvokerHelper.removeClass(script);
}
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsTwoDifferentSslContextParametersGetTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsTwoDifferentSslContextParametersGetTest.java
index 2d6acb2..38a25e6 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsTwoDifferentSslContextParametersGetTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsTwoDifferentSslContextParametersGetTest.java
@@ -87,7 +87,7 @@ public class HttpsTwoDifferentSslContextParametersGetTest extends BaseHttpsTest
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = (IllegalArgumentException) e.getCause().getCause();
assertNotNull(iae);
assertTrue(iae.getMessage().startsWith("Only same instance of SSLContextParameters is supported."));
diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java
index ed9c7c2..d5ab95f 100644
--- a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationSpringTest.java
@@ -29,11 +29,11 @@ public class CamelJaxbNoNamespaceSchemaLocationSpringTest extends CamelJaxbNoNam
setUseRouteBuilder(false);
final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/jaxb/CamelJaxbNoNamespaceSchemaLocationTest.xml");
setCamelContextService(new Service() {
- public void start() throws Exception {
+ public void start() {
applicationContext.start();
}
- public void stop() throws Exception {
+ public void stop() {
applicationContext.stop();
}
});
diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java
index 07a05dc..ea06f3b 100644
--- a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java
@@ -29,11 +29,11 @@ public class CamelJaxbSpringTest extends CamelJaxbTest {
setUseRouteBuilder(false);
final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/jaxb/CamelJaxbTest.xml");
setCamelContextService(new Service() {
- public void start() throws Exception {
+ public void start() {
applicationContext.start();
}
- public void stop() throws Exception {
+ public void stop() {
applicationContext.stop();
}
});
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
index ad15dff..c53524b 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
@@ -485,7 +485,7 @@ public class JmsEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
}
@Override
- public void stop() throws Exception {
+ public void stop() {
int running = runningMessageListeners.get();
if (running <= 0) {
super.stop();
@@ -495,7 +495,7 @@ public class JmsEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
}
@Override
- public void shutdown() throws Exception {
+ public void shutdown() {
int running = runningMessageListeners.get();
if (running <= 0) {
super.shutdown();
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
index dbea19b..40aaecd 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
@@ -20,6 +20,7 @@ import com.ibm.as400.access.AS400;
import com.ibm.as400.access.BaseDataQueue;
import com.ibm.as400.access.DataQueue;
import com.ibm.as400.access.KeyedDataQueue;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.Service;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
@@ -58,7 +59,7 @@ class Jt400DataQueueService implements Service {
}
@Override
- public void start() throws Exception {
+ public void start() {
if (queue == null) {
AS400 system = endpoint.getSystem();
if (endpoint.isKeyed()) {
@@ -69,12 +70,16 @@ class Jt400DataQueueService implements Service {
}
if (!queue.getSystem().isConnected(AS400.DATAQUEUE)) {
LOG.info("Connecting to {}", endpoint);
- queue.getSystem().connectService(AS400.DATAQUEUE);
+ try {
+ queue.getSystem().connectService(AS400.DATAQUEUE);
+ } catch (Exception e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
}
}
@Override
- public void stop() throws Exception {
+ public void stop() {
if (queue != null) {
LOG.info("Releasing connection to {}", endpoint);
AS400 system = queue.getSystem();
diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalancePartitionRevokeTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalancePartitionRevokeTest.java
index a3fbc88..15ccbba 100644
--- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalancePartitionRevokeTest.java
+++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalancePartitionRevokeTest.java
@@ -99,11 +99,11 @@ public class KafkaConsumerRebalancePartitionRevokeTest extends BaseEmbeddedKafka
}
@Override
- public void start() throws Exception {
+ public void start() {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
}
@Override
diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalanceTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalanceTest.java
index 349ee71..d1f799c 100644
--- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalanceTest.java
+++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerRebalanceTest.java
@@ -80,11 +80,11 @@ public class KafkaConsumerRebalanceTest extends BaseEmbeddedKafkaTest {
}
@Override
- public void start() throws Exception {
+ public void start() {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
}
@Override
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/KubernetesLeadershipController.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/KubernetesLeadershipController.java
index 8a3f9cb..2035253 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/KubernetesLeadershipController.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/KubernetesLeadershipController.java
@@ -75,7 +75,7 @@ public class KubernetesLeadershipController implements Service {
}
@Override
- public void start() throws Exception {
+ public void start() {
if (serializedExecutor == null) {
LOG.debug("{} Starting leadership controller...", logPrefix());
serializedExecutor = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "CamelKubernetesLeadershipController");
@@ -87,7 +87,7 @@ public class KubernetesLeadershipController implements Service {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
LOG.debug("{} Stopping leadership controller...", logPrefix());
if (serializedExecutor != null) {
serializedExecutor.shutdownNow();
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/TimedLeaderNotifier.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/TimedLeaderNotifier.java
index 4b82b09..383b4b9 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/TimedLeaderNotifier.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cluster/lock/TimedLeaderNotifier.java
@@ -92,20 +92,24 @@ public class TimedLeaderNotifier implements Service {
}
@Override
- public void start() throws Exception {
+ public void start() {
if (this.executor == null) {
this.executor = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "CamelKubernetesLeaderNotifier");
}
}
@Override
- public void stop() throws Exception {
+ public void stop() {
if (this.executor != null) {
ScheduledExecutorService executor = this.executor;
this.executor = null;
executor.shutdownNow();
- executor.awaitTermination(1, TimeUnit.SECONDS);
+ try {
+ executor.awaitTermination(1, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ // ignore
+ }
}
}
diff --git a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexProducer.java b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexProducer.java
index ce87fee..874958a 100644
--- a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexProducer.java
+++ b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexProducer.java
@@ -30,11 +30,8 @@ public class LuceneIndexProducer extends DefaultProducer {
this.indexer = indexer;
}
- public void start() throws Exception {
- super.doStart();
- }
-
- public void stop() throws Exception {
+ @Override
+ public void doStop() throws Exception {
this.indexer.getNiofsDirectory().close();
super.doStop();
}
diff --git a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneQueryProducer.java b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneQueryProducer.java
index 0fe5ee6..5448e30 100644
--- a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneQueryProducer.java
+++ b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneQueryProducer.java
@@ -39,12 +39,14 @@ public class LuceneQueryProducer extends DefaultProducer {
maxNumberOfHits = config.getMaxHits();
}
- public void start() throws Exception {
+ @Override
+ public void doStart() throws Exception {
searcher = new LuceneSearcher();
super.doStart();
}
- public void stop() throws Exception {
+ @Override
+ public void doStop() throws Exception {
searcher.close();
super.doStop();
}
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerBootstrapFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerBootstrapFactory.java
index bd83155..d4a1d26 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerBootstrapFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerBootstrapFactory.java
@@ -88,7 +88,7 @@ public class HttpServerBootstrapFactory extends SingleTCPNettyServerBootstrapFac
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// only stop if no more active consumers
int consumers = channelFactory.consumers();
if (consumers == 0) {
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java
index 8348a3d..7203ce2 100644
--- a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java
@@ -15,13 +15,12 @@
* limitations under the License.
*/
package org.apache.camel.component.quartz2;
+
import java.io.InputStream;
import java.util.Properties;
import org.junit.After;
import org.junit.Test;
-import org.quartz.SchedulerException;
-
public class QuartzPropertiesTest extends BaseQuartzTest {
@@ -60,7 +59,7 @@ public class QuartzPropertiesTest extends BaseQuartzTest {
try {
quartz.start();
fail("Should have thrown exception");
- } catch (SchedulerException e) {
+ } catch (Exception e) {
assertEquals("Error loading Quartz properties file: doesnotexist.properties", e.getMessage());
}
}
diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestService.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestService.java
index 23ee9bd..65e54e2 100644
--- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestService.java
+++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestService.java
@@ -38,12 +38,12 @@ public class ReactiveStreamsTestService implements CamelReactiveStreamsService {
}
@Override
- public void start() throws Exception {
+ public void start() {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
}
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java
index f0759b6..3ecd926 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.restlet;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jackson.JacksonDataFormat;
import org.apache.camel.impl.JndiRegistry;
@@ -58,7 +57,7 @@ public class RestRestletCustomDataFormatInvalidTest extends RestletTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getCause().getMessage().contains("JsonDataFormat name: bla must not be an existing bean instance from the registry"));
}
}
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
index 72230af..328306a 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
@@ -385,11 +385,8 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
subscriptionHelper = null;
}
if (session != null && session.getAccessToken() != null) {
- try {
- // logout of Salesforce
- ServiceHelper.stopService(session);
- } catch (SalesforceException ignored) {
- }
+ // logout of Salesforce
+ ServiceHelper.stopService(session);
}
} finally {
if (httpClient != null) {
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/SalesforceSession.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/SalesforceSession.java
index 685c783..8af3d8a 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/SalesforceSession.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/SalesforceSession.java
@@ -38,6 +38,7 @@ import java.util.concurrent.TimeoutException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.Service;
import org.apache.camel.component.salesforce.AuthenticationType;
import org.apache.camel.component.salesforce.SalesforceHttpClient;
@@ -355,15 +356,23 @@ public class SalesforceSession implements Service {
}
@Override
- public void start() throws Exception {
+ public void start() {
// auto-login at start if needed
- login(accessToken);
+ try {
+ login(accessToken);
+ } catch (SalesforceException e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// logout
- logout();
+ try {
+ logout();
+ } catch (SalesforceException e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
}
public long getTimeout() {
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/AbstractClientBase.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/AbstractClientBase.java
index 479207d..3251057 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/AbstractClientBase.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/AbstractClientBase.java
@@ -100,12 +100,16 @@ public abstract class AbstractClientBase implements SalesforceSession.Salesforce
this.terminationTimeout = terminationTimeout;
}
- public void start() throws Exception {
+ public void start() {
// local cache
accessToken = session.getAccessToken();
if (accessToken == null) {
// lazy login here!
- accessToken = session.login(accessToken);
+ try {
+ accessToken = session.login(accessToken);
+ } catch (SalesforceException e) {
+ throw new RuntimeException(e);
+ }
}
instanceUrl = session.getInstanceUrl();
@@ -116,7 +120,7 @@ public abstract class AbstractClientBase implements SalesforceSession.Salesforce
}
@Override
- public void stop() throws Exception {
+ public void stop() {
if (inflightRequests != null) {
inflightRequests.arrive();
if (!inflightRequests.isTerminated()) {
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java
index 36d26e2..c870de5 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AbstractRestProcessor.java
@@ -94,12 +94,12 @@ public abstract class AbstractRestProcessor extends AbstractSalesforceProcessor
}
@Override
- public void start() throws Exception {
+ public void start() {
ServiceHelper.startService(restClient);
}
@Override
- public void stop() throws Exception {
+ public void stop() {
ServiceHelper.stopService(restClient);
}
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AnalyticsApiProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AnalyticsApiProcessor.java
index a3e5776..944e923 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AnalyticsApiProcessor.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/AnalyticsApiProcessor.java
@@ -222,12 +222,12 @@ public class AnalyticsApiProcessor extends AbstractSalesforceProcessor {
}
@Override
- public void start() throws Exception {
+ public void start() {
ServiceHelper.startService(analyticsClient);
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// stop the client
ServiceHelper.stopService(analyticsClient);
}
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java
index 67cc41c..42de8c0 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/BulkApiProcessor.java
@@ -434,12 +434,12 @@ public class BulkApiProcessor extends AbstractSalesforceProcessor {
}
@Override
- public void start() throws Exception {
+ public void start() {
ServiceHelper.startService(bulkClient);
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// stop the client
ServiceHelper.stopService(bulkClient);
}
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/CompositeApiProcessor.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/CompositeApiProcessor.java
index ed31c22..86f3279 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/CompositeApiProcessor.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/processor/CompositeApiProcessor.java
@@ -95,12 +95,12 @@ public final class CompositeApiProcessor extends AbstractSalesforceProcessor {
}
@Override
- public void start() throws Exception {
+ public void start() {
ServiceHelper.startService(compositeClient);
}
@Override
- public void stop() throws Exception {
+ public void stop() {
ServiceHelper.stopService(compositeClient);
}
diff --git a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
index 9ec4d14..783f8f2 100644
--- a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
+++ b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
@@ -492,7 +492,7 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
}
@Override
- public void stop() throws Exception {
+ public void stop() {
if (getConsumers().isEmpty()) {
super.stop();
} else {
@@ -501,7 +501,7 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
}
@Override
- public void shutdown() throws Exception {
+ public void shutdown() {
if (isShutdown()) {
log.trace("Service already shut down");
return;
diff --git a/components/camel-spring/src/main/java/org/apache/camel/language/spel/SpelLanguage.java b/components/camel-spring/src/main/java/org/apache/camel/language/spel/SpelLanguage.java
index 708614f..f5ed197 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/language/spel/SpelLanguage.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/language/spel/SpelLanguage.java
@@ -47,7 +47,7 @@ public class SpelLanguage extends LanguageSupport implements Service {
}
@Override
- public void start() throws Exception {
+ public void start() {
ObjectHelper.notNull(getCamelContext(), "CamelContext", this);
if (getCamelContext() instanceof SpringCamelContext) {
@@ -59,7 +59,7 @@ public class SpelLanguage extends LanguageSupport implements Service {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// noop
}
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/JavaDslTransactedNoTXManagerTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/JavaDslTransactedNoTXManagerTest.java
index f623b9f..60574d6 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/JavaDslTransactedNoTXManagerTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/JavaDslTransactedNoTXManagerTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.spring.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.NoSuchBeanException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -40,7 +39,7 @@ public class JavaDslTransactedNoTXManagerTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
assertEquals("No bean could be found in the registry of type: PlatformTransactionManager", cause.getMessage());
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
index def4260..10b2b79 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
@@ -33,11 +33,11 @@ public final class SpringTestHelper {
final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(classpathUri);
test.setCamelContextService(new Service() {
- public void start() throws Exception {
+ public void start() {
applicationContext.start();
}
- public void stop() throws Exception {
+ public void stop() {
applicationContext.stop();
}
});
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java
index 65b3420..36443c2 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/MultiRestConsumer.java
@@ -71,14 +71,14 @@ public class MultiRestConsumer implements Consumer {
}
@Override
- public void start() throws Exception {
+ public void start() {
for (Consumer consumer : this.delegateConsumers) {
consumer.start();
}
}
@Override
- public void stop() throws Exception {
+ public void stop() {
for (Consumer consumer : this.delegateConsumers) {
consumer.stop();
}
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/MemoryWebsocketStore.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/MemoryWebsocketStore.java
index b0afac5..e9310b9 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/MemoryWebsocketStore.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/MemoryWebsocketStore.java
@@ -49,12 +49,12 @@ public class MemoryWebsocketStore extends ConcurrentHashMap<String, DefaultWebso
}
@Override
- public void start() throws Exception {
+ public void start() {
// noop
}
@Override
- public void stop() throws Exception {
+ public void stop() {
clear();
}
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalDomainObjectJSONTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalDomainObjectJSONTest.java
index 851cc88..4a10494 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalDomainObjectJSONTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalDomainObjectJSONTest.java
@@ -29,12 +29,12 @@ public class SpringMarshalDomainObjectJSONTest extends MarshalDomainObjectJSONTe
final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/dataformat/xstream/SpringMarshalDomainObjectJSONTest.xml");
setCamelContextService(new Service() {
- public void start() throws Exception {
+ public void start() {
applicationContext.start();
}
- public void stop() throws Exception {
+ public void stop() {
applicationContext.stop();
}
});
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalListTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalListTest.java
index 86cbc41..f2d03b3 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalListTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalListTest.java
@@ -29,12 +29,12 @@ public class SpringMarshalListTest extends MarshalListTest {
final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/dataformat/xstream/SpringMarshalListTest.xml");
setCamelContextService(new Service() {
- public void start() throws Exception {
+ public void start() {
applicationContext.start();
}
- public void stop() throws Exception {
+ public void stop() {
applicationContext.stop();
}
});
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalOmitFieldsTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalOmitFieldsTest.java
index 8c3d4cb..c1fe4b7 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalOmitFieldsTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringMarshalOmitFieldsTest.java
@@ -31,11 +31,11 @@ public class SpringMarshalOmitFieldsTest extends XStreamDataFormatOmitFieldsTest
"org/apache/camel/dataformat/xstream/SpringMarshalOmitFieldsTest.xml");
setCamelContextService(new Service() {
- public void start() throws Exception {
+ public void start() {
applicationContext.start();
}
- public void stop() throws Exception {
+ public void stop() {
applicationContext.stop();
}
});
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.java b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.java
index 9cf564a..57f3e32 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.java
@@ -31,11 +31,11 @@ public class SpringXStreamConfigurationTest extends XStreamConfigurationTest {
"org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.xml");
setCamelContextService(new Service() {
- public void start() throws Exception {
+ public void start() {
applicationContext.start();
}
- public void stop() throws Exception {
+ public void stop() {
applicationContext.stop();
}
});
[camel] 06/11: CAMEL-13522: camel3 - The various Camel exceptions
should favour extending runtime exception
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4d6ecbae193c3f0250ed89e5323db44ea2128f78
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 13:30:07 2019 +0200
CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
---
.../java/org/apache/camel/AlreadyStoppedException.java | 3 +--
.../org/apache/camel/CamelAuthorizationException.java | 2 +-
.../src/main/java/org/apache/camel/CamelException.java | 1 -
.../java/org/apache/camel/CamelExchangeException.java | 1 -
.../java/org/apache/camel/CamelExecutionException.java | 1 -
.../java/org/apache/camel/CamelUnitOfWorkException.java | 4 ++--
.../java/org/apache/camel/ExchangeTimedOutException.java | 1 -
.../java/org/apache/camel/ExpectedBodyTypeException.java | 2 +-
.../org/apache/camel/ExpressionEvaluationException.java | 2 --
.../apache/camel/ExpressionIllegalSyntaxException.java | 1 -
.../apache/camel/FailedToCreateConsumerException.java | 1 -
.../apache/camel/FailedToCreateProducerException.java | 1 -
.../org/apache/camel/FailedToCreateRouteException.java | 4 ++--
.../org/apache/camel/FailedToStartRouteException.java | 3 +--
.../java/org/apache/camel/InvalidPayloadException.java | 1 -
.../org/apache/camel/InvalidPayloadRuntimeException.java | 1 -
.../java/org/apache/camel/InvalidPropertyException.java | 2 +-
.../java/org/apache/camel/LoadPropertiesException.java | 2 +-
.../org/apache/camel/NoFactoryAvailableException.java | 3 +--
.../main/java/org/apache/camel/NoSuchBeanException.java | 2 +-
.../java/org/apache/camel/NoSuchEndpointException.java | 5 ++---
.../java/org/apache/camel/NoSuchHeaderException.java | 2 +-
.../java/org/apache/camel/NoSuchLanguageException.java | 2 +-
.../java/org/apache/camel/NoSuchPropertyException.java | 2 +-
.../apache/camel/NoTypeConversionAvailableException.java | 1 -
.../org/apache/camel/ProxyInstantiationException.java | 1 -
.../org/apache/camel/ResolveEndpointFailedException.java | 1 -
.../java/org/apache/camel/RollbackExchangeException.java | 1 -
.../java/org/apache/camel/RuntimeCamelException.java | 16 ++++++++++++++++
.../java/org/apache/camel/RuntimeExchangeException.java | 1 -
.../org/apache/camel/RuntimeExpressionException.java | 2 --
.../java/org/apache/camel/RuntimeTransformException.java | 2 --
.../java/org/apache/camel/TypeConversionException.java | 1 -
.../org/apache/camel/TypeConverterLoaderException.java | 3 +--
.../main/java/org/apache/camel/ValidationException.java | 1 -
.../org/apache/camel/VetoCamelContextStartException.java | 2 +-
.../org/apache/camel/support/service/ServiceSupport.java | 12 ++++++------
.../apache/camel/impl/engine/AbstractCamelContext.java | 6 +++---
.../org/apache/camel/impl/engine/BaseRouteService.java | 2 +-
.../DirectVmTwoCamelContextDuplicateConsumerTest.java | 4 ++--
.../camel/impl/LifecycleStrategyFailOnStartupTest.java | 4 ++--
.../processor/WeightedRoundRobinLoadBalanceTest.java | 2 +-
.../AggregateUnknownExecutorServiceRefTest.java | 5 ++---
.../onexception/OnExceptionHandledAndContinueTest.java | 4 ++--
.../onexception/OnExceptionMisconfiguredTest.java | 10 +++++-----
45 files changed, 59 insertions(+), 71 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/AlreadyStoppedException.java b/core/camel-api/src/main/java/org/apache/camel/AlreadyStoppedException.java
index ec06aee..2e37d83 100644
--- a/core/camel-api/src/main/java/org/apache/camel/AlreadyStoppedException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/AlreadyStoppedException.java
@@ -19,8 +19,7 @@ package org.apache.camel;
/**
* Exception thrown in situations when a {@link Service} has already been stopped.
*/
-public class AlreadyStoppedException extends CamelException {
- private static final long serialVersionUID = -8721487434390572639L;
+public class AlreadyStoppedException extends RuntimeCamelException {
public AlreadyStoppedException() {
super("Already stopped");
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java b/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java
index b2f0167..0e4e46c 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java
@@ -22,7 +22,7 @@ package org.apache.camel;
* Camel should not process the message as a result.
*/
public class CamelAuthorizationException extends CamelExchangeException {
- private static final long serialVersionUID = 1L;
+
private final String policyId;
public CamelAuthorizationException(String message, Exchange exchange) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelException.java b/core/camel-api/src/main/java/org/apache/camel/CamelException.java
index 61b0e22..d4031cc 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* Base class for all Camel checked exceptions typically thrown by a {@link Processor}
*/
public class CamelException extends Exception {
- private static final long serialVersionUID = -8721487434390572630L;
public CamelException() {
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java b/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java
index 6894658..4339677 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel;
-
/**
* An exception caused by a specific message {@link Exchange}
*/
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java b/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java
index c910612..2823525 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java
@@ -23,7 +23,6 @@ package org.apache.camel;
* to send messages to Camel.
*/
public class CamelExecutionException extends RuntimeExchangeException {
- private static final long serialVersionUID = -5821095325248904305L;
public CamelExecutionException(String message, Exchange exchange) {
super(message, exchange);
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelUnitOfWorkException.java b/core/camel-api/src/main/java/org/apache/camel/CamelUnitOfWorkException.java
index 7e95f55..9d335eb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelUnitOfWorkException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelUnitOfWorkException.java
@@ -26,8 +26,8 @@ import java.util.List;
* from the {@link #getCauses()} method.
*/
public class CamelUnitOfWorkException extends CamelExchangeException {
- private static final long serialVersionUID = 1L;
- private final List<Exception> causes;
+
+ private transient final List<Exception> causes;
public CamelUnitOfWorkException(Exchange exchange, List<Exception> causes) {
// just provide the first exception as cause, as it will be logged in the stacktraces
diff --git a/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java b/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java
index 2c8ac85..43c2308 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* An exception thrown if an InOut exchange times out receiving the OUT message
*/
public class ExchangeTimedOutException extends CamelExchangeException {
- private static final long serialVersionUID = -7899162905421788853L;
private final long timeout;
diff --git a/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java b/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java
index 5a02b1f..ea5385db 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java
@@ -20,7 +20,7 @@ package org.apache.camel;
* Thrown if the body could not be converted to the required type
*/
public class ExpectedBodyTypeException extends RuntimeCamelException {
- private static final long serialVersionUID = -7121445152234363768L;
+
private final transient Exchange exchange;
private final transient Class<?> expectedBodyType;
diff --git a/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java b/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java
index ba05253..6854ae7 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java
@@ -21,8 +21,6 @@ package org.apache.camel;
*/
public class ExpressionEvaluationException extends RuntimeCamelException {
- private static final long serialVersionUID = 2939802714638174540L;
-
private final transient Expression expression;
private final transient Exchange exchange;
diff --git a/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java b/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java
index 6dfa46d..6102eda 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* An exception thrown if the expression contains illegal syntax.
*/
public class ExpressionIllegalSyntaxException extends RuntimeCamelException {
- private static final long serialVersionUID = 6545652894842621836L;
private final String expression;
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
index ddac88a2..e1ac1fb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* Thrown if Camel failed to create a consumer for a given endpoint.
*/
public class FailedToCreateConsumerException extends RuntimeCamelException {
- private static final long serialVersionUID = 1916718168052020246L;
private final String uri;
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java
index 7bfcc5f..5a1ab7e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* Thrown if Camel failed to create a producer for a given endpoint.
*/
public class FailedToCreateProducerException extends RuntimeCamelException {
- private static final long serialVersionUID = 1341435621084082033L;
private final String uri;
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java
index 1c67a99..921ac53 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java
@@ -21,8 +21,8 @@ import org.apache.camel.util.URISupport;
/**
* Exception when failing to create a {@link org.apache.camel.Route}.
*/
-public class FailedToCreateRouteException extends CamelException {
- private static final long serialVersionUID = 1L;
+public class FailedToCreateRouteException extends RuntimeCamelException {
+
private final String routeId;
public FailedToCreateRouteException(String routeId, String route, Throwable cause) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
index c172a11..35f3fff 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
@@ -19,8 +19,7 @@ package org.apache.camel;
/**
* Exception when failing to start a {@link Route}.
*/
-public class FailedToStartRouteException extends CamelException {
- private static final long serialVersionUID = -6118520819865759888L;
+public class FailedToStartRouteException extends RuntimeCamelException {
public FailedToStartRouteException(String routeId, String message) {
super("Failed to start route " + routeId + " because of " + message);
diff --git a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java
index 507e9d1..127fc15 100644
--- a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java
@@ -21,7 +21,6 @@ package org.apache.camel;
*/
public class InvalidPayloadException extends CamelExchangeException {
- private static final long serialVersionUID = -1689157578733908632L;
private final transient Class<?> type;
public InvalidPayloadException(Exchange exchange, Class<?> type) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java
index 2ef0f0d..c87b522 100644
--- a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java
@@ -21,7 +21,6 @@ package org.apache.camel;
*/
public class InvalidPayloadRuntimeException extends RuntimeExchangeException {
- private static final long serialVersionUID = -155083097523464793L;
private final transient Class<?> type;
public InvalidPayloadRuntimeException(Exchange exchange, Class<?> type) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java b/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java
index 1a9155f..490f816 100644
--- a/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java
@@ -20,7 +20,7 @@ package org.apache.camel;
* An exception caused when an invalid property name is used on an object
*/
public class InvalidPropertyException extends RuntimeCamelException {
- private static final long serialVersionUID = 3450859794325167954L;
+
private final transient Object owner;
private final String propertyName;
diff --git a/core/camel-api/src/main/java/org/apache/camel/LoadPropertiesException.java b/core/camel-api/src/main/java/org/apache/camel/LoadPropertiesException.java
index df93662..501c49e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/LoadPropertiesException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/LoadPropertiesException.java
@@ -22,7 +22,7 @@ import java.net.URL;
* Represents a failure to open a Properties file at a given URL
*/
public class LoadPropertiesException extends CamelException {
- private static final long serialVersionUID = 3684303677685065529L;
+
private final URL url;
public LoadPropertiesException(URL url, Exception cause) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java b/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java
index 7a42052..ec42b21 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java
@@ -22,12 +22,11 @@ import java.io.IOException;
* Thrown if no factory resource is available for the given URI
*/
public class NoFactoryAvailableException extends IOException {
- private static final long serialVersionUID = -425141860196708627L;
private final String uri;
public NoFactoryAvailableException(String uri) {
- super("Could not find factory class for resource: " + uri);
+ super("Cannot find factory class for resource: " + uri);
this.uri = uri;
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java
index fc07e16..73c85ef 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java
@@ -20,7 +20,7 @@ package org.apache.camel;
* A runtime exception if a given bean could not be found in the {@link org.apache.camel.spi.Registry}
*/
public class NoSuchBeanException extends RuntimeCamelException {
- private static final long serialVersionUID = -8721487431101572630L;
+
private final String name;
public NoSuchBeanException(String name) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java
index ff92204..7a9c9cb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java
@@ -18,11 +18,10 @@ package org.apache.camel;
/**
* A runtime exception thrown if a routing processor such as a
- * {@link org.apache.camel.processor.RecipientList RecipientList} is unable to resolve an
- * {@link Endpoint} from a URI.
+ * recipient list is unable to resolve an {@link Endpoint} from a URI.
*/
public class NoSuchEndpointException extends RuntimeCamelException {
- private static final long serialVersionUID = -8721487431101572630L;
+
private final String uri;
public NoSuchEndpointException(String uri) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java
index 5abd3f4..59e86cd 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java
@@ -23,7 +23,7 @@ package org.apache.camel;
* @see org.apache.camel.support.ExchangeHelper#getMandatoryHeader(Exchange, String, Class)
*/
public class NoSuchHeaderException extends CamelExchangeException {
- private static final long serialVersionUID = -8721487431101572630L;
+
private final String headerName;
private final transient Class<?> type;
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchLanguageException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchLanguageException.java
index f415e18..1b84804 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchLanguageException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchLanguageException.java
@@ -23,7 +23,7 @@ package org.apache.camel;
* @see org.apache.camel.CamelContext#resolveLanguage(String)
*/
public class NoSuchLanguageException extends RuntimeCamelException {
- private static final long serialVersionUID = -8721487431101572630L;
+
private final String language;
public NoSuchLanguageException(String language) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java
index d4ad00d..6ce1e7b 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java
@@ -24,7 +24,7 @@ package org.apache.camel;
*
*/
public class NoSuchPropertyException extends CamelExchangeException {
- private static final long serialVersionUID = -8721487431101572630L;
+
private final String propertyName;
private final transient Class<?> type;
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java b/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java
index 6a5f172..d9e56d9 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* An exception thrown if a value could not be converted to the required type
*/
public class NoTypeConversionAvailableException extends CamelException {
- private static final long serialVersionUID = -8721487434390572636L;
private final transient Object value;
private final transient Class<?> type;
diff --git a/core/camel-api/src/main/java/org/apache/camel/ProxyInstantiationException.java b/core/camel-api/src/main/java/org/apache/camel/ProxyInstantiationException.java
index decc1db..26858ce 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ProxyInstantiationException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ProxyInstantiationException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* Exception indicating a failure while trying to create a proxy of a given type and on a given endpoint
*/
public class ProxyInstantiationException extends RuntimeCamelException {
- private static final long serialVersionUID = -2050115486047385506L;
private final Class<?> type;
private final Endpoint endpoint;
diff --git a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java
index f919861..ed0915b 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* A runtime exception thrown if an {@link Endpoint} cannot be resolved via URI
*/
public class ResolveEndpointFailedException extends RuntimeCamelException {
- private static final long serialVersionUID = -9121465713858552263L;
private final String uri;
diff --git a/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java b/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java
index 42c634b..e4b7feb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* Exception used for forcing an Exchange to be rolled back.
*/
public class RollbackExchangeException extends CamelExchangeException {
- private static final long serialVersionUID = -7837446508365767066L;
public RollbackExchangeException(Exchange exchange) {
this("Intended rollback", exchange);
diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java
index ad2b040..67a4e8c1 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java
@@ -52,4 +52,20 @@ public class RuntimeCamelException extends RuntimeException {
return new RuntimeCamelException(e);
}
}
+
+ /**
+ * Wraps the caused exception in a {@link RuntimeCamelException} if its not
+ * already a runtime exception.
+ *
+ * @param e the caused exception
+ * @return the wrapper exception
+ */
+ public static RuntimeException wrapRuntimeException(Throwable e) {
+ if (e instanceof RuntimeException) {
+ // don't double wrap
+ return (RuntimeException) e;
+ } else {
+ return new RuntimeCamelException(e);
+ }
+ }
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java
index 173455c..ebd4be8 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* A runtime exception caused by a specific message {@link Exchange}
*/
public class RuntimeExchangeException extends RuntimeCamelException {
- private static final long serialVersionUID = -8721487431101572630L;
private final transient Exchange exchange;
public RuntimeExchangeException(String message, Exchange exchange) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java
index 788be87..5e3b524 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java
@@ -21,8 +21,6 @@ package org.apache.camel;
*/
public class RuntimeExpressionException extends RuntimeCamelException {
- private static final long serialVersionUID = -8417806626073055262L;
-
public RuntimeExpressionException(String message) {
super(message);
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java
index fd6346f..2138d92 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java
@@ -21,8 +21,6 @@ package org.apache.camel;
*/
public class RuntimeTransformException extends RuntimeCamelException {
- private static final long serialVersionUID = -8417806626073055262L;
-
public RuntimeTransformException(String message) {
super(message);
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java b/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java
index c2c4332..5134fd9 100644
--- a/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java
@@ -20,7 +20,6 @@ package org.apache.camel;
* Exception when failing during type conversion.
*/
public class TypeConversionException extends RuntimeCamelException {
- private static final long serialVersionUID = -6118520819865759886L;
private final transient Object value;
private final transient Class<?> type;
diff --git a/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java b/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java
index 5ec1b2e..e23d011 100644
--- a/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java
@@ -19,8 +19,7 @@ package org.apache.camel;
/**
* Exception when failing to load type converters.
*/
-public class TypeConverterLoaderException extends CamelException {
- private static final long serialVersionUID = -6118520819865759887L;
+public class TypeConverterLoaderException extends RuntimeCamelException {
public TypeConverterLoaderException(String message) {
super("Failed to load type converters because of: " + message);
diff --git a/core/camel-api/src/main/java/org/apache/camel/ValidationException.java b/core/camel-api/src/main/java/org/apache/camel/ValidationException.java
index cebdc89..66798be 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ValidationException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ValidationException.java
@@ -23,7 +23,6 @@ package org.apache.camel;
* of the particular validation technology used.
*/
public class ValidationException extends CamelExchangeException {
- private static final long serialVersionUID = -7485357452450907415L;
public ValidationException(Exchange exchange, String message) {
super(message, exchange);
diff --git a/core/camel-api/src/main/java/org/apache/camel/VetoCamelContextStartException.java b/core/camel-api/src/main/java/org/apache/camel/VetoCamelContextStartException.java
index 5c3700b..16a8dfb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/VetoCamelContextStartException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/VetoCamelContextStartException.java
@@ -25,7 +25,7 @@ package org.apache.camel;
* @see org.apache.camel.spi.LifecycleStrategy
*/
public class VetoCamelContextStartException extends Exception {
- private static final long serialVersionUID = 8046489554418284257L;
+
private final CamelContext context;
private final boolean rethrowException;
diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
index accfb46..71119d7 100644
--- a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
+++ b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
@@ -60,7 +60,7 @@ public abstract class ServiceSupport implements StatefulService {
try {
doInit();
} catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
status = INITIALIZED;
}
@@ -100,7 +100,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while starting service: " + this, e);
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
}
@@ -130,7 +130,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while stopping service: " + this, e);
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
}
@@ -161,7 +161,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while suspending service: " + this, e);
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
}
@@ -188,7 +188,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while resuming service: " + this, e);
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
}
@@ -220,7 +220,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error shutting down service: " + this, e);
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 95bc12b..51aa0aa 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -2171,7 +2171,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
try {
doStartOrResumeRoutes(routeServices, true, true, false, true);
} catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
@@ -2195,7 +2195,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
return;
}
} else {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
@@ -2229,7 +2229,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
try {
((ExtendedStartupListener)startup).onCamelContextFullyStarted(this, isStarted());
} catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
}
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java
index b2b3097..bc76fe4 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java
@@ -205,7 +205,7 @@ public abstract class BaseRouteService extends ChildServiceSupport {
try {
warmUp();
} catch (FailedToStartRouteException e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ throw RuntimeCamelException.wrapRuntimeException(e);
}
try (MDCHelper mdcHelper = new MDCHelper(route.getId())) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
index 75ad01f..1b37fe7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
@@ -34,8 +34,8 @@ public class DirectVmTwoCamelContextDuplicateConsumerTest extends AbstractDirect
try {
third.start();
fail("Should have thrown exception");
- } catch (IllegalStateException e) {
- assertEquals("A consumer Consumer[direct-vm://foo] already exists from CamelContext: camel-1. Multiple consumers not supported", e.getMessage());
+ } catch (Exception e) {
+ assertEquals("A consumer Consumer[direct-vm://foo] already exists from CamelContext: camel-1. Multiple consumers not supported", e.getCause().getMessage());
}
// stop first camel context then
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
index ef57f29..1c5d1f1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
@@ -38,8 +38,8 @@ public class LifecycleStrategyFailOnStartupTest extends TestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (IllegalArgumentException e) {
- assertEquals("Forced", e.getMessage());
+ } catch (Exception e) {
+ assertEquals("Forced", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java
index 7dd0b52..4afa96d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java
@@ -130,7 +130,7 @@ public class WeightedRoundRobinLoadBalanceTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Loadbalacing with 3 should match number of distributions 2", iae.getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
index 87f06ce..b9692e5 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor.aggregator;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.BodyInAggregatingStrategy;
import org.junit.Test;
@@ -48,8 +47,8 @@ public class AggregateUnknownExecutorServiceRefTest extends ContextTestSupport {
});
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
- IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ } catch (Exception e) {
+ IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertTrue(cause.getMessage().contains("myUnknownProfile"));
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
index 3c1f8c2..38c360c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
@@ -45,8 +45,8 @@ public class OnExceptionHandledAndContinueTest extends ContextTestSupport {
context.start();
fail("Should thrown an exception");
} catch (Exception e) {
- assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
- assertTrue(e.getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
+ assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ assertTrue(e.getCause().getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
index a56cab4..6475f91 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
@@ -48,7 +48,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -67,7 +67,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -87,7 +87,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -107,7 +107,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -128,7 +128,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertTrue(iae.getMessage().startsWith("At least one exception must be configured"));
}
}
[camel] 01/11: CAMEL-13501: Component should move initialization
logic to doInit instead of doStart
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2f5df13a08b5429ca6d4fadcd01b228c4b9d98ed
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 09:39:35 2019 +0200
CAMEL-13501: Component should move initialization logic to doInit instead of doStart
---
.../apache/camel/support/service/ServiceSupport.java | 16 +++++++++++++---
.../camel/impl/engine/AbstractCamelContext.java | 7 +++++--
.../apache/camel/processor/UnitOfWorkProducer.java | 8 ++++++--
.../camel/processor/interceptor/DefaultDebugger.java | 5 -----
.../apache/camel/language/simple/SimpleLanguage.java | 8 ++++++--
.../org/apache/camel/support/ChildServiceSupport.java | 17 +++++++++++++++--
.../apache/camel/support/ScheduledPollConsumer.java | 19 +++++++++++++------
.../camel/support/SynchronousDelegateProducer.java | 4 ++++
8 files changed, 62 insertions(+), 22 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
index e257ac0..5d8d40f 100644
--- a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
+++ b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
@@ -56,7 +56,11 @@ public abstract class ServiceSupport implements StatefulService {
synchronized (lock) {
if (status == NEW) {
log.trace("Initializing service: {}", this);
- doInit();
+ try {
+ doInit();
+ } catch (Exception e) {
+ throw new RuntimeException("Error initializing service", e);
+ }
status = INITIALIZED;
}
}
@@ -79,7 +83,13 @@ public abstract class ServiceSupport implements StatefulService {
log.trace("Service: {} already starting", this);
return;
}
- init();
+ try {
+ init();
+ } catch (Exception e) {
+ status = FAILED;
+ log.trace("Error while initializing service: " + this, e);
+ throw e;
+ }
try {
status = STARTING;
log.trace("Starting service: {}", this);
@@ -304,7 +314,7 @@ public abstract class ServiceSupport implements StatefulService {
* Initialize the service.
* This method will only be called once before starting.
*/
- protected void doInit() {
+ protected void doInit() throws Exception {
}
/**
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 29b6ff8..567ab6a 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.function.Supplier;
-import org.apache.camel.AsyncProcessor;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.Component;
@@ -307,7 +306,11 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
this.startupListeners.add(deferStartupListener);
if (init) {
- init();
+ try {
+ init();
+ } catch (Exception e) {
+ throw new RuntimeException("Error initializing CamelContext", e);
+ }
}
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/UnitOfWorkProducer.java b/core/camel-base/src/main/java/org/apache/camel/processor/UnitOfWorkProducer.java
index c3181f7..c406a40 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/UnitOfWorkProducer.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/UnitOfWorkProducer.java
@@ -55,11 +55,15 @@ public final class UnitOfWorkProducer extends DefaultAsyncProducer {
return processor.process(exchange, callback);
}
- public void start() throws Exception {
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
ServiceHelper.startService(processor);
}
- public void stop() throws Exception {
+ @Override
+ protected void doStop() throws Exception {
+ super.doStop();
ServiceHelper.stopService(processor);
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/interceptor/DefaultDebugger.java b/core/camel-base/src/main/java/org/apache/camel/processor/interceptor/DefaultDebugger.java
index 0007433..538ebbf 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/interceptor/DefaultDebugger.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/interceptor/DefaultDebugger.java
@@ -330,11 +330,6 @@ public class DefaultDebugger extends ServiceSupport implements Debugger, CamelCo
}
@Override
- public void start() throws Exception {
- super.start();
- }
-
- @Override
protected void doStart() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext", this);
diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
index 947efb1..2809e31 100644
--- a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
+++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
@@ -118,8 +118,7 @@ public class SimpleLanguage extends LanguageSupport implements StaticService {
}
@Override
- @SuppressWarnings("unchecked")
- public void start() throws Exception {
+ public void init() {
// setup cache which requires CamelContext to be set first
if (cacheExpression == null && cachePredicate == null && getCamelContext() != null) {
int maxSize = CamelContextHelper.getMaximumSimpleCacheSize(getCamelContext());
@@ -134,6 +133,11 @@ public class SimpleLanguage extends LanguageSupport implements StaticService {
}
@Override
+ public void start() throws Exception {
+ // noop
+ }
+
+ @Override
public void stop() throws Exception {
if (cachePredicate instanceof LRUCache) {
if (LOG.isDebugEnabled()) {
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
index 0f3a3db..fdbc8eb 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
@@ -40,9 +40,16 @@ public abstract class ChildServiceSupport extends ServiceSupport {
log.trace("Service: {} already starting", this);
return;
}
- status = STARTING;
- log.trace("Starting service: {}", this);
try {
+ initService(childServices);
+ } catch (Exception e) {
+ status = FAILED;
+ log.trace("Error while initializing service: " + this, e);
+ throw e;
+ }
+ try {
+ status = STARTING;
+ log.trace("Starting service: {}", this);
ServiceHelper.startService(childServices);
doStart();
status = STARTED;
@@ -125,4 +132,10 @@ public abstract class ChildServiceSupport extends ServiceSupport {
return childServices != null && childServices.remove(childService);
}
+ private void initService(List<Service> services) {
+ if (services != null) {
+ services.forEach(Service::init);
+ }
+ }
+
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
index e90aff3..2bc5e2f 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
@@ -399,8 +399,8 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements R
protected abstract int poll() throws Exception;
@Override
- protected void doStart() throws Exception {
- super.doStart();
+ protected void doInit() throws Exception {
+ super.doInit();
// validate that if backoff multiplier is in use, the threshold values is set correctly
if (backoffMultiplier > 0) {
@@ -415,7 +415,6 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements R
}
scheduler.setCamelContext(getEndpoint().getCamelContext());
scheduler.onInit(this);
- scheduler.scheduleTask(this);
// configure scheduler with options from this consumer
Map<String, Object> properties = new HashMap<>();
@@ -435,11 +434,19 @@ public abstract class ScheduledPollConsumer extends DefaultConsumer implements R
ObjectHelper.notNull(scheduler, "scheduler", this);
ObjectHelper.notNull(pollStrategy, "pollStrategy", this);
+ }
- ServiceHelper.startService(scheduler);
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ if (scheduler != null) {
+ scheduler.scheduleTask(this);
+ ServiceHelper.startService(scheduler);
- if (isStartScheduler()) {
- startScheduler();
+ if (isStartScheduler()) {
+ startScheduler();
+ }
}
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java b/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java
index 2f99647..6531945 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java
@@ -46,6 +46,10 @@ public class SynchronousDelegateProducer implements Producer {
producer.process(exchange);
}
+ public void init() {
+ producer.init();
+ }
+
public void start() throws Exception {
producer.start();
}
[camel] 10/11: CAMEL-13522: camel3 - The various Camel exceptions
should favour extending runtime exception
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 9394829bdeb1afcb69cc5d2ae6d8cfbc6cbf4a65
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed May 15 09:48:04 2019 +0200
CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
---
.../org/apache/camel/component/activemq/CamelMessageConsumer.java | 2 --
.../org/apache/camel/component/activemq/CamelMessageProducer.java | 2 --
.../main/java/org/apache/camel/component/ahc/ws/WsConsumer.java | 8 ++++----
.../component/atmosphere/websocket/MemoryWebSocketStore.java | 4 ++--
.../java/org/apache/camel/component/cometd/CometdConsumer.java | 8 ++++----
.../java/org/apache/camel/component/cometd/CometdProducer.java | 7 +++----
.../java/org/apache/camel/component/ehcache/EhcacheManager.java | 4 ++--
.../camel/component/file/remote/FtpConsumerIdempotentRefTest.java | 4 ++--
.../guava/eventbus/GuavaEventBusConsumerConfigurationTest.java | 3 +--
.../camel/component/hazelcast/HazelcastErrorMessagesTest.java | 4 ++--
components/camel-infinispan/pom.xml | 1 -
.../org/apache/camel/component/infinispan/InfinispanManager.java | 8 ++++----
components/camel-infinispan/src/test/resources/log4j.xml | 2 +-
.../camel/component/jms/JmsTestConnectionOnStartupTest.java | 8 +++-----
.../java/org/apache/camel/component/mina2/Mina2EncodingTest.java | 2 +-
.../org/apache/camel/component/quartz2/QuartzPropertiesTest.java | 2 +-
.../camel/component/reactive/streams/BasicPublisherTest.java | 4 ++--
.../camel/component/reactor/engine/ReactorStreamsServiceTest.java | 4 ++--
.../camel/component/rxjava2/engine/RxJavaStreamsServiceTest.java | 4 ++--
.../org/apache/camel/component/xslt/SaxonInvalidXsltFileTest.java | 2 +-
.../org/apache/camel/component/servlet/HttpClientRouteTest.java | 2 +-
.../apache/camel/component/sjms/batch/SjmsBatchEndpointTest.java | 5 +++--
.../camel/component/sjms/producer/NoConnectionFactoryTest.java | 6 +++---
.../camel/component/sjms/tx/TransactedProducerInOutErrorTest.java | 6 +++---
.../camel/component/spring/batch/SpringBatchEndpointTest.java | 8 ++++----
.../camel/spring/boot/SupervisingRouteControllerRestartTest.java | 2 +-
components/readme.adoc | 2 +-
27 files changed, 53 insertions(+), 61 deletions(-)
diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageConsumer.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageConsumer.java
index 8fe1c0b..7cb0ebc 100644
--- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageConsumer.java
+++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageConsumer.java
@@ -63,8 +63,6 @@ public class CamelMessageConsumer implements MessageConsumer {
if (pollingConsumer != null) {
pollingConsumer.stop();
}
- } catch (JMSException e) {
- throw e;
} catch (Exception e) {
throw JMSExceptionSupport.create(e);
}
diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageProducer.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageProducer.java
index 71230cc..a9ed0e8 100644
--- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageProducer.java
+++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/CamelMessageProducer.java
@@ -69,8 +69,6 @@ public class CamelMessageProducer extends ActiveMQMessageProducerSupport {
closed = true;
try {
producer.stop();
- } catch (JMSException e) {
- throw e;
} catch (Exception e) {
throw JMSExceptionSupport.create(e);
}
diff --git a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsConsumer.java b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsConsumer.java
index b447f20..5041415 100644
--- a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsConsumer.java
+++ b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsConsumer.java
@@ -31,15 +31,15 @@ public class WsConsumer extends DefaultConsumer {
}
@Override
- public void start() throws Exception {
- super.start();
+ public void doStart() throws Exception {
+ super.doStart();
getEndpoint().connect(this);
}
@Override
- public void stop() throws Exception {
+ public void doStop() throws Exception {
getEndpoint().disconnect(this);
- super.stop();
+ super.doStop();
}
@Override
diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/MemoryWebSocketStore.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/MemoryWebSocketStore.java
index b6fca1c..90436cd 100644
--- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/MemoryWebSocketStore.java
+++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/MemoryWebSocketStore.java
@@ -42,14 +42,14 @@ public class MemoryWebSocketStore implements WebSocketStore {
* @see org.apache.camel.Service#start()
*/
@Override
- public void start() throws Exception {
+ public void start() {
}
/* (non-Javadoc)
* @see org.apache.camel.Service#stop()
*/
@Override
- public void stop() throws Exception {
+ public void stop() {
values.clear();
keys.clear();
}
diff --git a/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdConsumer.java b/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdConsumer.java
index 4d808f3..335f679 100644
--- a/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdConsumer.java
+++ b/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdConsumer.java
@@ -42,8 +42,8 @@ public class CometdConsumer extends DefaultConsumer implements CometdProducerCon
}
@Override
- public void start() throws Exception {
- super.start();
+ public void doStart() throws Exception {
+ super.doStart();
// must connect first
endpoint.connect(this);
// should probably look into synchronization for this.
@@ -53,9 +53,9 @@ public class CometdConsumer extends DefaultConsumer implements CometdProducerCon
}
@Override
- public void stop() throws Exception {
+ public void doStop() throws Exception {
endpoint.disconnect(this);
- super.stop();
+ super.doStop();
}
public void setBayeux(BayeuxServerImpl bayeux) {
diff --git a/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdProducer.java b/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdProducer.java
index a9feb31..6807df7 100644
--- a/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdProducer.java
+++ b/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdProducer.java
@@ -43,10 +43,9 @@ public class CometdProducer extends DefaultProducer implements CometdProducerCon
}
@Override
- public void start() throws Exception {
- super.start();
+ public void doStart() throws Exception {
+ super.doStart();
// must connect first
-
endpoint.connect(this);
// should probably look into synchronization for this.
if (service == null) {
@@ -55,7 +54,7 @@ public class CometdProducer extends DefaultProducer implements CometdProducerCon
}
@Override
- public void stop() throws Exception {
+ public void doStop() throws Exception {
super.stop();
endpoint.disconnect(this);
}
diff --git a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheManager.java b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheManager.java
index 9d363b7..bcbe578 100644
--- a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheManager.java
+++ b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheManager.java
@@ -52,12 +52,12 @@ public class EhcacheManager implements Service {
}
@Override
- public synchronized void start() throws Exception {
+ public synchronized void start() {
refCount.retain();
}
@Override
- public synchronized void stop() throws Exception {
+ public synchronized void stop() {
refCount.release();
userCaches.values().forEach(UserManagedCache::close);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java
index 50eb0b1..bf9ea47 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java
@@ -103,10 +103,10 @@ public class FtpConsumerIdempotentRefTest extends FtpServerTestSupport {
return;
}
- public void start() throws Exception {
+ public void start() {
}
- public void stop() throws Exception {
+ public void stop() {
}
}
}
\ No newline at end of file
diff --git a/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java b/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java
index 59bf8ea1..4832543 100644
--- a/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java
+++ b/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.guava.eventbus;
import com.google.common.eventbus.EventBus;
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.SimpleRegistry;
@@ -49,7 +48,7 @@ public class GuavaEventBusConsumerConfigurationTest extends CamelTestSupport {
try {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalStateException ise = assertIsInstanceOf(IllegalStateException.class, e.getCause());
assertEquals("You cannot set both 'eventClass' and 'listenerInterface' parameters.", ise.getMessage());
}
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
index 76e2a68..ae810b1 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java
@@ -33,7 +33,7 @@ public class HazelcastErrorMessagesTest extends HazelcastCamelTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- assertTrue(e.getMessage().contains("You cannot send messages to this endpoint: hazelcast-atomicvalue://foo"));
+ assertTrue(e.getCause().getMessage().contains("You cannot send messages to this endpoint: hazelcast-atomicvalue://foo"));
}
}
@@ -50,7 +50,7 @@ public class HazelcastErrorMessagesTest extends HazelcastCamelTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- assertTrue(e.getMessage().contains("You cannot send messages to this endpoint: hazelcast-instance://foo"));
+ assertTrue(e.getCause().getMessage().contains("You cannot send messages to this endpoint: hazelcast-instance://foo"));
}
}
diff --git a/components/camel-infinispan/pom.xml b/components/camel-infinispan/pom.xml
index e4b882a..000d925 100644
--- a/components/camel-infinispan/pom.xml
+++ b/components/camel-infinispan/pom.xml
@@ -37,7 +37,6 @@
</properties>
<dependencies>
- <!-- TODO: requires camel-core -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java
index 75b5f3a..fa36cf2 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanManager.java
@@ -22,7 +22,7 @@ import java.util.Properties;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
-import org.apache.camel.Service;
+import org.apache.camel.support.service.ServiceSupport;
import org.apache.camel.util.ObjectHelper;
import org.infinispan.cache.impl.DecoratedCache;
import org.infinispan.client.hotrod.RemoteCacheManager;
@@ -33,7 +33,7 @@ import org.infinispan.manager.DefaultCacheManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class InfinispanManager implements Service {
+public class InfinispanManager extends ServiceSupport {
private static final transient Logger LOGGER = LoggerFactory.getLogger(InfinispanManager.class);
private final InfinispanConfiguration configuration;
@@ -57,7 +57,7 @@ public class InfinispanManager implements Service {
}
@Override
- public void start() throws Exception {
+ public void doStart() throws Exception {
cacheContainer = configuration.getCacheContainer();
if (cacheContainer == null) {
@@ -129,7 +129,7 @@ public class InfinispanManager implements Service {
}
@Override
- public void stop() throws Exception {
+ public void doStop() throws Exception {
if (isManagedCacheContainer) {
cacheContainer.stop();
}
diff --git a/components/camel-infinispan/src/test/resources/log4j.xml b/components/camel-infinispan/src/test/resources/log4j.xml
index b4b65ac..e4081f2 100644
--- a/components/camel-infinispan/src/test/resources/log4j.xml
+++ b/components/camel-infinispan/src/test/resources/log4j.xml
@@ -82,7 +82,7 @@
<root>
<priority value="INFO" />
- <appender-ref ref="CONSOLE" />
+ <appender-ref ref="FILE" />
</root>
</log4j:configuration>
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java
index 262a12c..db1af79 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java
@@ -20,9 +20,7 @@ import javax.jms.ConnectionFactory;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToCreateConsumerException;
import org.apache.camel.FailedToCreateProducerException;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
@@ -43,7 +41,7 @@ public class JmsTestConnectionOnStartupTest extends CamelTestSupport {
try {
context.start();
fail("Should have thrown an exception");
- } catch (FailedToCreateConsumerException e) {
+ } catch (Exception e) {
assertEquals("Failed to create Consumer for endpoint: activemq://queue:foo?testConnectionOnStartup=true. "
+ "Reason: Cannot get JMS Connection on startup for destination foo", e.getMessage());
}
@@ -61,8 +59,8 @@ public class JmsTestConnectionOnStartupTest extends CamelTestSupport {
try {
context.start();
fail("Should have thrown an exception");
- } catch (FailedToCreateRouteException ex) {
- FailedToCreateProducerException e = (FailedToCreateProducerException) ex.getCause();
+ } catch (Exception ex) {
+ FailedToCreateProducerException e = assertIsInstanceOf(FailedToCreateProducerException.class, ex.getCause());
assertTrue(e.getMessage().startsWith("Failed to create Producer for endpoint: activemq://queue:foo?testConnectionOnStartup=true."));
assertTrue(e.getMessage().contains("java.net.ConnectException"));
}
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java
index ace5eac..741ad1f 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2EncodingTest.java
@@ -193,7 +193,7 @@ public class Mina2EncodingTest extends BaseMina2Test {
}
});
fail("Should have thrown a ResolveEndpointFailedException due invalid encoding parameter");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("The encoding: XXX is not supported", iae.getMessage());
}
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java
index 7203ce2..c16b882 100644
--- a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzPropertiesTest.java
@@ -60,7 +60,7 @@ public class QuartzPropertiesTest extends BaseQuartzTest {
quartz.start();
fail("Should have thrown exception");
} catch (Exception e) {
- assertEquals("Error loading Quartz properties file: doesnotexist.properties", e.getMessage());
+ assertEquals("Error loading Quartz properties file: doesnotexist.properties", e.getCause().getMessage());
}
}
diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java
index 9e9cccc..1ea3d6b 100644
--- a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java
+++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BasicPublisherTest.java
@@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import org.apache.camel.Exchange;
-import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams;
import org.apache.camel.test.junit4.CamelTestSupport;
@@ -104,7 +104,7 @@ public class BasicPublisherTest extends CamelTestSupport {
disp3.dispose();
}
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void testOnlyOneCamelProducerPerPublisher() throws Exception {
new RouteBuilder() {
diff --git a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java
index abd1614..af56887 100644
--- a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java
+++ b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import org.apache.camel.Exchange;
-import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -394,7 +394,7 @@ public class ReactorStreamsServiceTest extends ReactorStreamsServiceTestSupport
// misc
// ************************************************
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void testOnlyOneCamelProducerPerPublisher() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
diff --git a/components/camel-rxjava2/src/test/java/org/apache/camel/component/rxjava2/engine/RxJavaStreamsServiceTest.java b/components/camel-rxjava2/src/test/java/org/apache/camel/component/rxjava2/engine/RxJavaStreamsServiceTest.java
index 3d6edf6..c440b4d 100644
--- a/components/camel-rxjava2/src/test/java/org/apache/camel/component/rxjava2/engine/RxJavaStreamsServiceTest.java
+++ b/components/camel-rxjava2/src/test/java/org/apache/camel/component/rxjava2/engine/RxJavaStreamsServiceTest.java
@@ -24,7 +24,7 @@ import java.util.function.Function;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import org.apache.camel.Exchange;
-import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -386,7 +386,7 @@ public class RxJavaStreamsServiceTest extends RxJavaStreamsServiceTestSupport {
// misc
// ************************************************
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void testOnlyOneCamelProducerPerPublisher() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
diff --git a/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonInvalidXsltFileTest.java b/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonInvalidXsltFileTest.java
index f0fe9ef..3658606 100644
--- a/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonInvalidXsltFileTest.java
+++ b/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonInvalidXsltFileTest.java
@@ -37,7 +37,7 @@ public class SaxonInvalidXsltFileTest extends TestSupport {
fail("Should have thrown an exception due XSL compilation error");
} catch (Exception e) {
// expected
- assertIsInstanceOf(TransformerException.class, e.getCause());
+ assertIsInstanceOf(TransformerException.class, e.getCause().getCause());
}
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
index 94e5f2c..e489853 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
@@ -122,7 +122,7 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
}
});
fail("Excepts exception here");
- } catch (FailedToCreateRouteException ex) {
+ } catch (Exception ex) {
assertTrue("Get a wrong exception.", ex.getCause() instanceof FailedToCreateProducerException);
assertTrue("Get a wrong cause of exception.", ex.getCause().getCause() instanceof UnsupportedOperationException);
}
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpointTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpointTest.java
index aee1551..a1fba4e 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpointTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpointTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.sjms.batch;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.AggregationStrategies;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.sjms.SjmsComponent;
@@ -87,7 +88,7 @@ public class SjmsBatchEndpointTest extends CamelTestSupport {
context.start();
}
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void testConsumerNegativePollDuration() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
@@ -99,7 +100,7 @@ public class SjmsBatchEndpointTest extends CamelTestSupport {
context.start();
}
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void testConsumerNegativeConsumerCount() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/NoConnectionFactoryTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/NoConnectionFactoryTest.java
index b66e1af..553fc37 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/NoConnectionFactoryTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/NoConnectionFactoryTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.sjms.producer;
import org.apache.camel.CamelContext;
import org.apache.camel.FailedToCreateProducerException;
-import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.junit.Assert;
@@ -69,7 +69,7 @@ public class NoConnectionFactoryTest {
try {
context.start();
} catch (Throwable t) {
- Assert.assertEquals(FailedToCreateRouteException.class, t.getClass());
+ Assert.assertEquals(FailedToStartRouteException.class, t.getClass());
Assert.assertEquals(FailedToCreateProducerException.class, t.getCause().getClass());
Assert.assertEquals(IllegalArgumentException.class, t.getCause().getCause().getClass());
LOG.info("Expected exception was thrown", t);
@@ -85,7 +85,7 @@ public class NoConnectionFactoryTest {
try {
context.start();
} catch (Throwable t) {
- Assert.assertEquals(FailedToCreateRouteException.class, t.getClass());
+ Assert.assertEquals(FailedToStartRouteException.class, t.getClass());
Assert.assertEquals(FailedToCreateProducerException.class, t.getCause().getClass());
Assert.assertEquals(IllegalArgumentException.class, t.getCause().getCause().getClass());
LOG.info("Expected exception was thrown", t);
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java
index 2d742d3..2a95b15 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.sjms.tx;
import org.apache.camel.CamelContext;
import org.apache.camel.FailedToCreateProducerException;
-import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.sjms.CamelJmsTestHelper;
import org.apache.camel.component.sjms.SjmsComponent;
@@ -35,7 +35,7 @@ public class TransactedProducerInOutErrorTest {
private static final Logger LOG = LoggerFactory.getLogger(TransactedProducerInOutErrorTest.class);
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void test() throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(createRouteBuilder());
@@ -44,7 +44,7 @@ public class TransactedProducerInOutErrorTest {
try {
context.start();
} catch (Throwable t) {
- Assert.assertEquals(FailedToCreateRouteException.class, t.getClass());
+ Assert.assertEquals(FailedToStartRouteException.class, t.getClass());
Assert.assertEquals(FailedToCreateProducerException.class, t.getCause().getClass());
Assert.assertEquals(IllegalArgumentException.class, t.getCause().getCause().getClass());
LOG.info("Exception was thrown as expected", t);
diff --git a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
index c028a63..e4e4ff2 100644
--- a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
+++ b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
@@ -23,7 +23,7 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.EndpointInject;
-import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
@@ -193,7 +193,7 @@ public class SpringBatchEndpointTest extends CamelTestSupport {
mockEndpoint.expectedBodiesReceived(jobExecution);
}
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void shouldThrowExceptionIfUsedAsConsumer() throws Exception {
// When
context().addRoutes(new RouteBuilder() {
@@ -303,7 +303,7 @@ public class SpringBatchEndpointTest extends CamelTestSupport {
assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
}
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void shouldFailWhenThereIsNoJobLauncher() throws Exception {
// Given
SimpleRegistry registry = new SimpleRegistry();
@@ -320,7 +320,7 @@ public class SpringBatchEndpointTest extends CamelTestSupport {
camelContext.start();
}
- @Test(expected = FailedToCreateRouteException.class)
+ @Test(expected = FailedToStartRouteException.class)
public void shouldFailWhenThereIsMoreThanOneJobLauncher() throws Exception {
// Given
SimpleRegistry registry = new SimpleRegistry();
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/SupervisingRouteControllerRestartTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/SupervisingRouteControllerRestartTest.java
index 381e574..654a007 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/SupervisingRouteControllerRestartTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/SupervisingRouteControllerRestartTest.java
@@ -84,7 +84,7 @@ public class SupervisingRouteControllerRestartTest {
try {
controller.startRoute("dummy");
} catch (Exception e) {
- Assert.assertEquals("Forced error on restart", e.getMessage());
+ Assert.assertEquals("Forced error on restart", e.getCause().getMessage());
}
Assert.assertTrue(controller.getBackOffContext("dummy").isPresent());
diff --git a/components/readme.adoc b/components/readme.adoc
index b24e55f..927e597 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -463,7 +463,7 @@ Number of Components: 295 in 232 JAR artifacts (0 deprecated)
| link:camel-jing/src/main/docs/jing-component.adoc[Jing] (camel-jing) +
`jing:resourceUri` | 1.1 | Validates the payload of a message using RelaxNG Syntax using Jing library.
-| link:@@@ARTIFACTID@@@/src/main/docs/jms-component.adoc[JMS] (@@@ARTIFACTID@@@) +
+| link:camel-jms/src/main/docs/jms-component.adoc[JMS] (camel-jms) +
`jms:destinationType:destinationName` | 1.0 | The jms component allows messages to be sent to (or consumed from) a JMS Queue or Topic.
| link:camel-jmx/src/main/docs/jmx-component.adoc[JMX] (camel-jmx) +
[camel] 09/11: CAMEL-13522: camel3 - The various Camel exceptions
should favour extending runtime exception
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e63e0323ab225c46c6e2a4973326dd2ca5037174
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 16:20:42 2019 +0200
CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
---
.../camel/spring/CircularComponentCreationTest.java | 6 ++----
.../ErrorHandlerCamelContextRefNotFoundTest.java | 5 +++--
.../ErrorHandlerRouteContextRefNotFoundTest.java | 4 ++--
.../spring/issues/SpringMainStartFailedIssueTest.java | 4 ++--
.../SpringCamelContextStartingFailedEventTest.java | 4 ++--
...pringDeadLetterChannelInvalidDeadLetterUriTest.java | 5 +++--
...eadLetterChannelInvalidOptionDeadLetterUriTest.java | 5 +++--
.../SpringDoubleLoadBalancerMisconfigurationTest.java | 5 +++--
.../spring/processor/SpringFilterNoChildTest.java | 5 +++--
...ringRouteWithConstantFieldFromExchangeFailTest.java | 18 ++----------------
.../processor/SpringTryCatchMisconfiguredTest.java | 8 ++++----
.../SpringTryCatchMustHaveExceptionConfiguredTest.java | 4 ++--
12 files changed, 31 insertions(+), 42 deletions(-)
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/CircularComponentCreationTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/CircularComponentCreationTest.java
index 735c186..e9700aa 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/CircularComponentCreationTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/CircularComponentCreationTest.java
@@ -16,9 +16,7 @@
*/
package org.apache.camel.spring;
-
import org.apache.camel.FailedToCreateRouteException;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.util.IOHelper;
import org.junit.Assert;
import org.junit.Test;
@@ -32,8 +30,8 @@ public class CircularComponentCreationTest {
doTest("org/apache/camel/spring/CircularComponentCreationSimpleTest.xml");
Assert.fail("Exception should have been thrown");
- } catch (RuntimeCamelException e) {
- Assert.assertTrue(e.getCause() instanceof FailedToCreateRouteException);
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof FailedToCreateRouteException);
}
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
index eb1c5e8..06741a7 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.spring.config;
+
import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.NoSuchBeanException;
import org.apache.camel.RuntimeCamelException;
@@ -32,8 +33,8 @@ public class ErrorHandlerCamelContextRefNotFoundTest extends SpringTestSupport {
try {
super.setUp();
fail("Should have thrown an exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e);
NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
assertEquals("No bean could be found in the registry for: foo of type: org.apache.camel.builder.ErrorHandlerBuilder", nsbe.getMessage());
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java
index 5841dc3..5f9483d 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java
@@ -32,8 +32,8 @@ public class ErrorHandlerRouteContextRefNotFoundTest extends SpringTestSupport {
try {
super.setUp();
fail("Should have thrown exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e);
NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
assertEquals("No bean could be found in the registry for: bar of type: org.apache.camel.builder.ErrorHandlerBuilder", nsbe.getMessage());
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMainStartFailedIssueTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMainStartFailedIssueTest.java
index 9931751..b94b651 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMainStartFailedIssueTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMainStartFailedIssueTest.java
@@ -32,8 +32,8 @@ public class SpringMainStartFailedIssueTest extends TestSupport {
try {
main.run(args);
fail("Should have thrown an exception");
- } catch (RuntimeCamelException e) {
- assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ assertIsInstanceOf(FailedToCreateRouteException.class, e);
}
assertNull("Spring application context should NOT be created", main.getApplicationContext());
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java
index 805e24f..30d60d9 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java
@@ -35,8 +35,8 @@ public class SpringCamelContextStartingFailedEventTest extends SpringTestSupport
try {
new ClassPathXmlApplicationContext("org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.xml");
fail("Should thrown an exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertIsInstanceOf(ResolveEndpointFailedException.class, ftcre.getCause());
// expected
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java
index b2b1057..af771a2 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.spring.processor;
+
import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.RuntimeCamelException;
@@ -37,8 +38,8 @@ public class SpringDeadLetterChannelInvalidDeadLetterUriTest extends SpringTestS
try {
super.setUp();
fail("Should have thrown an exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e);
NoSuchEndpointException cause = assertIsInstanceOf(NoSuchEndpointException.class, ftcre.getCause());
assertEquals("No endpoint could be found for: xxx, please check your classpath contains the needed Camel component jar.", cause.getMessage());
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java
index bb57cfd..2d23645 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.spring.processor;
+
import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.RuntimeCamelException;
@@ -37,8 +38,8 @@ public class SpringDeadLetterChannelInvalidOptionDeadLetterUriTest extends Sprin
try {
super.setUp();
fail("Should have thrown an exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e);
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, ftcre.getCause());
assertTrue(cause.getMessage().endsWith("Unknown parameters=[{foo=bar}]"));
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java
index cf33f57..4930b79 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.spring.processor;
+
import org.apache.camel.CamelContext;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.FailedToCreateRouteException;
@@ -32,8 +33,8 @@ public class SpringDoubleLoadBalancerMisconfigurationTest extends ContextTestSup
try {
super.setUp();
fail("Should have thrown exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException fe = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException fe = assertIsInstanceOf(FailedToCreateRouteException.class, e);
IllegalArgumentException ie = assertIsInstanceOf(IllegalArgumentException.class, fe.getCause());
assertTrue(ie.getMessage().startsWith("Loadbalancer already configured to: RandomLoadBalancer. Cannot set it to: LoadBalanceType[RoundRobinLoadBalancer"));
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java
index 990f7eb..56bf920 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.spring.processor;
+
import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.spring.SpringTestSupport;
@@ -30,8 +31,8 @@ public class SpringFilterNoChildTest extends SpringTestSupport {
try {
new ClassPathXmlApplicationContext("org/apache/camel/spring/processor/filterNoChild.xml");
fail("Should thrown an exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e);
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Definition has no children on Filter[xpath{$foo = 'bar'} -> []]", iae.getMessage());
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteWithConstantFieldFromExchangeFailTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteWithConstantFieldFromExchangeFailTest.java
index e707fa4..2ac068c 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteWithConstantFieldFromExchangeFailTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteWithConstantFieldFromExchangeFailTest.java
@@ -15,30 +15,16 @@
* limitations under the License.
*/
package org.apache.camel.spring.processor;
+
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToCreateRouteException;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.processor.RouteWithConstantFieldFromExchangeFailTest;
-import org.junit.Before;
import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
public class SpringRouteWithConstantFieldFromExchangeFailTest extends RouteWithConstantFieldFromExchangeFailTest {
- @Override
- @Before
- public void setUp() throws Exception {
- try {
- super.setUp();
- fail("Should have thrown an exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException re = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, re.getCause());
- assertEquals("Constant field with name: XXX not found on Exchange.class", iae.getMessage());
- }
- }
-
protected CamelContext createCamelContext() throws Exception {
return createSpringCamelContext(this, "org/apache/camel/spring/processor/RouteWithConstantFieldFromExchangeFailTest.xml");
}
+
}
\ No newline at end of file
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMisconfiguredTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMisconfiguredTest.java
index bb1dafe..85bf262 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMisconfiguredTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMisconfiguredTest.java
@@ -31,8 +31,8 @@ public class SpringTryCatchMisconfiguredTest extends ContextTestSupport {
try {
createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringTryCatchMisconfiguredTest.xml");
fail("Should have thrown exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException ftce = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException ftce = assertIsInstanceOf(FailedToCreateRouteException.class, e);
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, ftce.getCause());
assertEquals("This doCatch should have a doTry as its parent on DoCatch[ [class java.io.IOException] -> [To[mock:fail]]]", iae.getMessage());
}
@@ -40,8 +40,8 @@ public class SpringTryCatchMisconfiguredTest extends ContextTestSupport {
try {
createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringTryCatchMisconfiguredFinallyTest.xml");
fail("Should have thrown exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e);
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, ftcre.getCause());
assertEquals("This doFinally should have a doTry as its parent on DoFinally[[To[mock:finally]]]", iae.getMessage());
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java
index 00eff42..0adf7cb 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.java
@@ -30,8 +30,8 @@ public class SpringTryCatchMustHaveExceptionConfiguredTest extends ContextTestSu
try {
createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringTryCatchMustHaveExceptionConfiguredTest.xml");
fail("Should have thrown exception");
- } catch (RuntimeCamelException e) {
- FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e);
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, ftcre.getCause());
assertEquals("At least one Exception must be configured to catch", iae.getMessage());
}
[camel] 03/11: CAMEL-13514: Service API should not use checked
exceptions in start/stop methods.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 414fd412ff07f60a3098e8acced2a1d53cc51376
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 10:39:53 2019 +0200
CAMEL-13514: Service API should not use checked exceptions in start/stop methods.
---
.../main/java/org/apache/camel/CamelContext.java | 8 ++--
.../apache/camel/FailedToStartRouteException.java | 4 ++
.../src/main/java/org/apache/camel/Service.java | 14 +++---
.../java/org/apache/camel/ShutdownableService.java | 4 +-
.../java/org/apache/camel/SuspendableService.java | 8 ++--
.../camel/support/service/ServiceHelper.java | 41 ++++++++---------
.../camel/support/service/ServiceSupport.java | 23 +++++-----
.../camel/impl/engine/AbstractCamelContext.java | 51 ++++++++++++++--------
.../camel/impl/engine/AbstractDynamicRegistry.java | 4 +-
.../apache/camel/impl/engine/BaseRouteService.java | 26 ++++++-----
.../impl/engine/DefaultClaimCheckRepository.java | 4 +-
.../engine/DefaultInterceptSendToEndpoint.java | 6 +--
.../org/apache/camel/impl/engine/DefaultRoute.java | 4 +-
.../camel/impl/engine/DefaultUnitOfWork.java | 4 +-
.../engine/InterceptSendToEndpointProcessor.java | 4 +-
.../engine/LimitedPollingConsumerPollStrategy.java | 4 +-
.../apache/camel/impl/engine/MDCUnitOfWork.java | 2 +-
.../impl/engine/ProvisionalEndpointRegistry.java | 4 +-
.../impl/DefaultRuntimeCamelCatalog.java | 4 +-
.../caffeine/lrucache/CaffeineLRUCacheTest.java | 4 +-
.../apache/camel/core/osgi/OsgiBeanRepository.java | 4 +-
.../core/osgi/test/MockTypeConverterRegistry.java | 4 +-
.../camel/language/simple/SimpleLanguage.java | 4 +-
.../org/apache/camel/SuspendableServiceTest.java | 4 +-
.../camel/component/bean/BeanInvokeStaticTest.java | 3 +-
.../camel/component/bean/BeanLifecycleTest.java | 12 ++---
.../component/bean/BeanRefMethodNotFoundTest.java | 5 ++-
.../camel/component/bean/BeanRefNotFoundTest.java | 7 +--
.../component/bean/BeanWithMethodHeaderTest.java | 5 +--
.../ClassComponentInvalidConfigurationTest.java | 5 +--
.../bean/MethodCallBeanRefMethodNotFoundTest.java | 5 ++-
.../bean/MethodCallBeanRefNotFoundTest.java | 7 +--
.../component/dataset/DataSetTestEndpointTest.java | 11 +++--
.../direct/DirectNoMultipleConsumersTest.java | 3 +-
.../file/FileConsumerCustomSchedulerTest.java | 6 +--
.../file/FileConsumerIdempotentRefTest.java | 4 +-
.../OptionalPropertiesDslInvalidSyntaxTest.java | 5 +--
.../properties/PropertiesComponentDefaultTest.java | 5 +--
...ropertiesComponentOnlyUseDefaultValuesTest.java | 5 +--
.../properties/PropertiesComponentTest.java | 17 ++++----
...meSedaQueueMultipleConsumersDifferenceTest.java | 7 +--
.../SedaBlockWhenFullInvalidConfigurationTest.java | 3 +-
.../component/timer/TimerWithTimeOptionTest.java | 3 +-
.../validator/ValidatorIllegalImportTest.java | 3 +-
.../camel/component/xslt/InvalidXsltFileTest.java | 3 +-
.../xslt/XsltCustomErrorListenerTest.java | 3 +-
.../camel/component/xslt/XsltFileNotFoundTest.java | 3 +-
.../component/xslt/XsltRouteXsltWithErrorTest.java | 3 +-
.../apache/camel/component/xslt/XsltSaxonTest.java | 3 +-
.../impl/DefaultCamelContextStopFailureTest.java | 4 +-
.../camel/impl/FromHasNoOutputRouteTest.java | 7 +--
.../GracefulShutdownNoAutoStartOrderClashTest.java | 5 +--
.../camel/impl/LifecycleStrategyServiceTest.java | 4 +-
.../camel/impl/MultipleConsumersSupportTest.java | 5 +--
.../impl/RouteMustHaveOutputOnExceptionTest.java | 3 +-
.../org/apache/camel/impl/RouteNoOutputTest.java | 7 +--
...ventNotifierServiceStoppingFailedEventTest.java | 4 +-
.../language/BeanLanguageInvalidOGNLTest.java | 3 +-
.../model/ProcessorTypeConfigurationTest.java | 3 +-
.../apache/camel/model/RoutePropertiesTest.java | 3 +-
.../model/StartingRoutesErrorReportedTest.java | 11 +++--
.../CreateRouteWithNonExistingEndpointTest.java | 3 +-
.../processor/ExchangeIdempotentConsumerTest.java | 4 +-
...dempotentConsumerUsingCustomRepositoryTest.java | 4 +-
.../processor/NewProcessorAndServiceTest.java | 4 +-
.../processor/RouteStartupOrderClashTest.java | 3 +-
...RouteWithConstantFieldFromExchangeFailTest.java | 3 +-
.../ThreadsCoreAndMaxPoolInvalidTest.java | 3 +-
.../camel/processor/ThreadsInvalidConfigTest.java | 13 +++---
.../processor/ThreadsZeroInCoreAndMaxPoolTest.java | 3 +-
.../processor/ThrottlerInvalidConfiguredTest.java | 3 +-
.../TryCatchMustHaveExceptionConfiguredTest.java | 3 +-
.../processor/WeightedRandomLoadBalanceTest.java | 3 +-
.../WeightedRoundRobinLoadBalanceTest.java | 3 +-
.../OnExceptionHandledAndContinueTest.java | 3 +-
.../onexception/OnExceptionMisconfiguredTest.java | 11 +++--
.../camel/management/ManagedDuplicateIdTest.java | 5 +--
.../TwoManagedCamelContextClashTest.java | 6 +--
.../support/AsyncProcessorConverterHelper.java | 4 +-
.../apache/camel/support/ChildServiceSupport.java | 15 ++++---
.../camel/support/SynchronousDelegateProducer.java | 9 ++--
.../support/management/MBeanInfoAssembler.java | 5 +--
82 files changed, 273 insertions(+), 271 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
index 5a92a38..2862fc6 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
@@ -138,18 +138,18 @@ public interface CamelContext extends StatefulService, RuntimeConfiguration {
* <p/>
* See more details at the class-level javadoc of this class.
*
- * @throws Exception is thrown if starting failed
+ * @throws RuntimeCamelException is thrown if starting failed
*/
- void start() throws Exception;
+ void start();
/**
* Stop and shutdown the {@link CamelContext} (will stop all routes/components/endpoints etc and clear internal state/cache).
* <p/>
* See more details at the class-level javadoc of this class.
*
- * @throws Exception is thrown if stopping failed
+ * @throws RuntimeCamelException is thrown if stopping failed
*/
- void stop() throws Exception;
+ void stop();
/**
* Gets the name (id) of the this CamelContext.
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
index 83355f1..c172a11 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
@@ -26,6 +26,10 @@ public class FailedToStartRouteException extends CamelException {
super("Failed to start route " + routeId + " because of " + message);
}
+ public FailedToStartRouteException(String routeId, String message, Throwable cause) {
+ super("Failed to start route " + routeId + " because of " + message, cause);
+ }
+
public FailedToStartRouteException(Throwable cause) {
super(cause);
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/Service.java b/core/camel-api/src/main/java/org/apache/camel/Service.java
index f601be4..78e6196 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Service.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Service.java
@@ -24,22 +24,22 @@ public interface Service {
/**
* Initialize the service
*
- * @throws RuntimeException is thrown if initialization failed
+ * @throws RuntimeCamelException is thrown if initialization failed
*/
default void init() {
}
/**
* Starts the service
- *
- * @throws Exception is thrown if starting failed
+ *
+ * @throws RuntimeCamelException is thrown if starting failed
*/
- void start() throws Exception;
+ void start();
/**
* Stops the service
- *
- * @throws Exception is thrown if stopping failed
+ *
+ * @throws RuntimeCamelException is thrown if stopping failed
*/
- void stop() throws Exception;
+ void stop();
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/ShutdownableService.java b/core/camel-api/src/main/java/org/apache/camel/ShutdownableService.java
index f76a88f..1572c73 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ShutdownableService.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ShutdownableService.java
@@ -29,8 +29,8 @@ public interface ShutdownableService extends Service {
/**
* Shutdown the service, which means it cannot be started again.
*
- * @throws Exception thrown if shutting down failed
+ * @throws RuntimeCamelException is thrown if shutdown failed
*/
- void shutdown() throws Exception;
+ void shutdown();
}
\ No newline at end of file
diff --git a/core/camel-api/src/main/java/org/apache/camel/SuspendableService.java b/core/camel-api/src/main/java/org/apache/camel/SuspendableService.java
index 11accde..259c3cb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/SuspendableService.java
+++ b/core/camel-api/src/main/java/org/apache/camel/SuspendableService.java
@@ -35,16 +35,16 @@ public interface SuspendableService extends Service {
/**
* Suspends the service.
*
- * @throws Exception is thrown if suspending failed
+ * @throws RuntimeCamelException is thrown if suspending failed
*/
- void suspend() throws Exception;
+ void suspend();
/**
* Resumes the service.
*
- * @throws Exception is thrown if resuming failed
+ * @throws RuntimeCamelException is thrown if resuming failed
*/
- void resume() throws Exception;
+ void resume();
/**
* Tests whether the service is suspended or not.
diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java
index 1de2bd6..1817e38 100644
--- a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java
+++ b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java
@@ -25,6 +25,7 @@ import java.util.Set;
import org.apache.camel.Channel;
import org.apache.camel.Navigate;
import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.Service;
import org.apache.camel.ShutdownableService;
import org.apache.camel.StatefulService;
@@ -50,7 +51,7 @@ public final class ServiceHelper {
* <p/>
* Calling this method has no effect if {@code value} is {@code null}.
*/
- public static void startService(Object value) throws Exception {
+ public static void startService(Object value) {
if (value instanceof Service) {
((Service) value).start();
} else if (value instanceof Iterable) {
@@ -66,7 +67,7 @@ public final class ServiceHelper {
*
* @see #startService(Object)
*/
- public static void startService(Object... services) throws Exception {
+ public static void startService(Object... services) {
if (services != null) {
for (Object o : services) {
startService(o);
@@ -83,7 +84,7 @@ public final class ServiceHelper {
*
* @see #stopService(Collection)
*/
- public static void stopService(Object... services) throws Exception {
+ public static void stopService(Object... services) {
if (services != null) {
for (Object o : services) {
stopService(o);
@@ -99,7 +100,7 @@ public final class ServiceHelper {
* @see Service#stop()
* @see #stopService(Collection)
*/
- public static void stopService(Object value) throws Exception {
+ public static void stopService(Object value) {
if (value instanceof Service) {
((Service) value).stop();
} else if (value instanceof Iterable) {
@@ -118,15 +119,15 @@ public final class ServiceHelper {
*
* @see #stopService(Object)
*/
- public static void stopService(Collection<?> services) throws Exception {
+ public static void stopService(Collection<?> services) {
if (services == null) {
return;
}
- Exception firstException = null;
+ RuntimeException firstException = null;
for (Object value : services) {
try {
stopService(value);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Caught exception stopping service: {}", value, e);
}
@@ -149,7 +150,7 @@ public final class ServiceHelper {
*
* @see #stopAndShutdownServices(Collection)
*/
- public static void stopAndShutdownServices(Object... services) throws Exception {
+ public static void stopAndShutdownServices(Object... services) {
if (services == null) {
return;
}
@@ -165,7 +166,7 @@ public final class ServiceHelper {
* @see #stopService(Object)
* @see ShutdownableService#shutdown()
*/
- public static void stopAndShutdownService(Object value) throws Exception {
+ public static void stopAndShutdownService(Object value) {
stopService(value);
// then try to shutdown
@@ -186,11 +187,11 @@ public final class ServiceHelper {
* @see #stopService(Object)
* @see ShutdownableService#shutdown()
*/
- public static void stopAndShutdownServices(Collection<?> services) throws Exception {
+ public static void stopAndShutdownServices(Collection<?> services) {
if (services == null) {
return;
}
- Exception firstException = null;
+ RuntimeException firstException = null;
for (Object value : services) {
@@ -204,7 +205,7 @@ public final class ServiceHelper {
LOG.trace("Shutting down service: {}", service);
service.shutdown();
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Caught exception shutting down service: {}", value, e);
}
@@ -227,17 +228,17 @@ public final class ServiceHelper {
*
* @see #resumeService(Object)
*/
- public static void resumeServices(Collection<?> services) throws Exception {
+ public static void resumeServices(Collection<?> services) {
if (services == null) {
return;
}
- Exception firstException = null;
+ RuntimeException firstException = null;
for (Object value : services) {
if (value instanceof Service) {
Service service = (Service)value;
try {
resumeService(service);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Caught exception resuming service: {}", service, e);
}
@@ -273,7 +274,7 @@ public final class ServiceHelper {
* @throws Exception is thrown if error occurred
* @see #startService(Object)
*/
- public static boolean resumeService(Object service) throws Exception {
+ public static boolean resumeService(Object service) {
if (service instanceof Suspendable && service instanceof SuspendableService) {
SuspendableService ss = (SuspendableService) service;
if (ss.isSuspended()) {
@@ -298,17 +299,17 @@ public final class ServiceHelper {
*
* @see #suspendService(Object)
*/
- public static void suspendServices(Collection<?> services) throws Exception {
+ public static void suspendServices(Collection<?> services) {
if (services == null) {
return;
}
- Exception firstException = null;
+ RuntimeException firstException = null;
for (Object value : services) {
if (value instanceof Service) {
Service service = (Service)value;
try {
suspendService(service);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Caught exception suspending service: {}", service, e);
}
@@ -344,7 +345,7 @@ public final class ServiceHelper {
* @throws Exception is thrown if error occurred
* @see #stopService(Object)
*/
- public static boolean suspendService(Object service) throws Exception {
+ public static boolean suspendService(Object service) {
if (service instanceof Suspendable && service instanceof SuspendableService) {
SuspendableService ss = (SuspendableService) service;
if (!ss.isSuspended()) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
index 5d8d40f..accfb46 100644
--- a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
+++ b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.support.service;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.ServiceStatus;
import org.apache.camel.StatefulService;
import org.slf4j.Logger;
@@ -59,7 +60,7 @@ public abstract class ServiceSupport implements StatefulService {
try {
doInit();
} catch (Exception e) {
- throw new RuntimeException("Error initializing service", e);
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
status = INITIALIZED;
}
@@ -73,7 +74,7 @@ public abstract class ServiceSupport implements StatefulService {
* <b>NOT</b> be overriden as they are used internally to keep track of the state of this service and properly
* invoke the operation in a safe manner.
*/
- public void start() throws Exception {
+ public void start() {
synchronized (lock) {
if (status == STARTED) {
log.trace("Service: {} already started", this);
@@ -99,7 +100,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while starting service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
@@ -110,7 +111,7 @@ public abstract class ServiceSupport implements StatefulService {
* <b>NOT</b> be overridden as they are used internally to keep track of the state of this service and properly
* invoke the operation in a safe manner.
*/
- public void stop() throws Exception {
+ public void stop() {
synchronized (lock) {
if (status == STOPPED || status == SHUTTINGDOWN || status == SHUTDOWN) {
log.trace("Service: {} already stopped", this);
@@ -129,7 +130,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while stopping service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
@@ -141,7 +142,7 @@ public abstract class ServiceSupport implements StatefulService {
* invoke the operation in a safe manner.
*/
@Override
- public void suspend() throws Exception {
+ public void suspend() {
synchronized (lock) {
if (status == SUSPENDED) {
log.trace("Service: {} already suspended", this);
@@ -160,7 +161,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while suspending service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
@@ -172,7 +173,7 @@ public abstract class ServiceSupport implements StatefulService {
* invoke the operation in a safe manner.
*/
@Override
- public void resume() throws Exception {
+ public void resume() {
synchronized (lock) {
if (status != SUSPENDED) {
log.trace("Service is not suspended: {}", this);
@@ -187,7 +188,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error while resuming service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
@@ -199,7 +200,7 @@ public abstract class ServiceSupport implements StatefulService {
* invoke the operation in a safe manner.
*/
@Override
- public void shutdown() throws Exception {
+ public void shutdown() {
synchronized (lock) {
if (status == SHUTDOWN) {
log.trace("Service: {} already shut down", this);
@@ -219,7 +220,7 @@ public abstract class ServiceSupport implements StatefulService {
} catch (Exception e) {
status = FAILED;
log.trace("Error shutting down service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 567ab6a..95bc12b 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -314,7 +314,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
}
}
- public void doInit() {
+ public void doInit() throws Exception {
// setup management first since end users may use it to add event
// notifiers
// using the management strategy before the CamelContext has been
@@ -2149,7 +2149,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
}
@Override
- public void start() throws Exception {
+ public void start() {
try (MDCHelper mdcHelper = new MDCHelper()) {
init();
vetoStarted.set(false);
@@ -2168,7 +2168,11 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
if (firstStartDone && !isAutoStartup() && isStarted()) {
// invoke this logic to warm up the routes and if possible also
// start the routes
- doStartOrResumeRoutes(routeServices, true, true, false, true);
+ try {
+ doStartOrResumeRoutes(routeServices, true, true, false, true);
+ } catch (Exception e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
}
// super will invoke doStart which will prepare internal services
@@ -2176,17 +2180,22 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
try {
firstStartDone = true;
super.start();
- } catch (VetoCamelContextStartException e) {
- // mark we veto against starting Camel
- vetoStarted.set(true);
- if (e.isRethrowException()) {
- throw e;
+ } catch (Exception e) {
+ VetoCamelContextStartException veto = ObjectHelper.getException(VetoCamelContextStartException.class, e);
+ if (veto != null) {
+ // mark we veto against starting Camel
+ vetoStarted.set(true);
+ if (veto.isRethrowException()) {
+ throw e;
+ } else {
+ log.info("CamelContext ({}) vetoed to not start due {}", getName(), e.getMessage());
+ // swallow exception and change state of this camel context
+ // to stopped
+ stop();
+ return;
+ }
} else {
- log.info("CamelContext ({}) vetoed to not start due {}", getName(), e.getMessage());
- // swallow exception and change state of this camel context
- // to stopped
- stop();
- return;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
@@ -2217,35 +2226,39 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
// now call the startup listeners where the routes has been started
for (StartupListener startup : startupListeners) {
if (startup instanceof ExtendedStartupListener) {
- ((ExtendedStartupListener)startup).onCamelContextFullyStarted(this, isStarted());
+ try {
+ ((ExtendedStartupListener)startup).onCamelContextFullyStarted(this, isStarted());
+ } catch (Exception e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
}
}
}
}
@Override
- public void stop() throws Exception {
+ public void stop() {
try (MDCHelper mdcHelper = new MDCHelper()) {
super.stop();
}
}
@Override
- public void suspend() throws Exception {
+ public void suspend() {
try (MDCHelper mdcHelper = new MDCHelper()) {
super.suspend();
}
}
@Override
- public void resume() throws Exception {
+ public void resume() {
try (MDCHelper mdcHelper = new MDCHelper()) {
super.resume();
}
}
@Override
- public void shutdown() throws Exception {
+ public void shutdown() {
try (MDCHelper mdcHelper = new MDCHelper()) {
super.shutdown();
}
@@ -2939,7 +2952,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Cam
return true;
}
- private void doWarmUpRoutes(Map<Integer, DefaultRouteStartupOrder> inputs, boolean autoStartup) throws Exception {
+ private void doWarmUpRoutes(Map<Integer, DefaultRouteStartupOrder> inputs, boolean autoStartup) throws FailedToStartRouteException {
// now prepare the routes by starting its services before we start the
// input
for (Map.Entry<Integer, DefaultRouteStartupOrder> entry : inputs.entrySet()) {
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java
index bf39044..0901e23 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractDynamicRegistry.java
@@ -52,7 +52,7 @@ public class AbstractDynamicRegistry<K, V> extends AbstractMap<K, V> implements
}
@Override
- public void start() throws Exception {
+ public void start() {
if (dynamicMap instanceof LRUCache) {
((LRUCache) dynamicMap).resetStatistics();
}
@@ -186,7 +186,7 @@ public class AbstractDynamicRegistry<K, V> extends AbstractMap<K, V> implements
}
@Override
- public void stop() throws Exception {
+ public void stop() {
ServiceHelper.stopService(staticMap.values(), dynamicMap.values());
purge();
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java
index 73fca8f..b2b3097 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/BaseRouteService.java
@@ -32,9 +32,11 @@ import org.apache.camel.Endpoint;
import org.apache.camel.EndpointAware;
import org.apache.camel.ErrorHandlerFactory;
import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.Processor;
import org.apache.camel.Route;
import org.apache.camel.RouteAware;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.Service;
import org.apache.camel.processor.ErrorHandler;
import org.apache.camel.spi.LifecycleStrategy;
@@ -126,11 +128,11 @@ public abstract class BaseRouteService extends ChildServiceSupport {
this.removingRoutes = removingRoutes;
}
- public void warmUp() throws Exception {
+ public void warmUp() throws FailedToStartRouteException {
try {
doWarmUp();
} catch (Exception e) {
- throw new FailedToCreateRouteException(id, getRouteDescription(), e);
+ throw new FailedToStartRouteException(id, getRouteDescription(), e);
}
}
@@ -199,8 +201,12 @@ public abstract class BaseRouteService extends ChildServiceSupport {
}
}
- protected void doStart() throws Exception {
- warmUp();
+ protected void doStart() {
+ try {
+ warmUp();
+ } catch (FailedToStartRouteException e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
try (MDCHelper mdcHelper = new MDCHelper(route.getId())) {
// start the route itself
@@ -218,7 +224,7 @@ public abstract class BaseRouteService extends ChildServiceSupport {
}
}
- protected void doStop() throws Exception {
+ protected void doStop() {
// if we are stopping CamelContext then we are shutting down
boolean isShutdownCamelContext = camelContext.isStopping();
@@ -263,7 +269,7 @@ public abstract class BaseRouteService extends ChildServiceSupport {
}
@Override
- protected void doShutdown() throws Exception {
+ protected void doShutdown() {
try (MDCHelper mdcHelper = new MDCHelper(route.getId())) {
log.debug("Shutting down services on route: {}", route.getId());
@@ -308,7 +314,7 @@ public abstract class BaseRouteService extends ChildServiceSupport {
}
@Override
- protected void doSuspend() throws Exception {
+ protected void doSuspend() {
// suspend and resume logic is provided by DefaultCamelContext which leverages ShutdownStrategy
// to safely suspend and resume
try (MDCHelper mdcHelper = new MDCHelper(route.getId())) {
@@ -321,7 +327,7 @@ public abstract class BaseRouteService extends ChildServiceSupport {
}
@Override
- protected void doResume() throws Exception {
+ protected void doResume() {
// suspend and resume logic is provided by DefaultCamelContext which leverages ShutdownStrategy
// to safely suspend and resume
try (MDCHelper mdcHelper = new MDCHelper(route.getId())) {
@@ -333,7 +339,7 @@ public abstract class BaseRouteService extends ChildServiceSupport {
}
}
- protected void startChildService(Route route, List<Service> services) throws Exception {
+ protected void startChildService(Route route, List<Service> services) {
for (Service service : services) {
log.debug("Starting child service on route: {} -> {}", route.getId(), service);
for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) {
@@ -344,7 +350,7 @@ public abstract class BaseRouteService extends ChildServiceSupport {
}
}
- protected void stopChildService(Route route, Set<Service> services, boolean shutdown) throws Exception {
+ protected void stopChildService(Route route, Set<Service> services, boolean shutdown) {
for (Service service : services) {
log.debug("{} child service on route: {} -> {}", shutdown ? "Shutting down" : "Stopping", route.getId(), service);
if (service instanceof ErrorHandler) {
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultClaimCheckRepository.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultClaimCheckRepository.java
index 5e1914f..5f76439 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultClaimCheckRepository.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultClaimCheckRepository.java
@@ -73,12 +73,12 @@ public class DefaultClaimCheckRepository implements ClaimCheckRepository {
}
@Override
- public void start() throws Exception {
+ public void start() {
// noop
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// noop
}
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultInterceptSendToEndpoint.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultInterceptSendToEndpoint.java
index d83396d..434bc6a 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultInterceptSendToEndpoint.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultInterceptSendToEndpoint.java
@@ -124,16 +124,16 @@ public class DefaultInterceptSendToEndpoint implements InterceptSendToEndpoint,
return delegate.isSingleton();
}
- public void start() throws Exception {
+ public void start() {
ServiceHelper.startService(detour, delegate);
}
- public void stop() throws Exception {
+ public void stop() {
ServiceHelper.stopService(delegate, detour);
}
@Override
- public void shutdown() throws Exception {
+ public void shutdown() {
ServiceHelper.stopAndShutdownServices(delegate, detour);
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java
index 7e2d7db..837dfca 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java
@@ -123,7 +123,7 @@ public abstract class DefaultRoute extends ServiceSupport implements Route {
* Do not invoke this method directly, use {@link org.apache.camel.spi.RouteController#startRoute(String)} to start a route.
*/
@Override
- public void start() throws Exception {
+ public void start() {
super.start();
}
@@ -131,7 +131,7 @@ public abstract class DefaultRoute extends ServiceSupport implements Route {
* Do not invoke this method directly, use {@link org.apache.camel.spi.RouteController#stopRoute(String)} to stop a route.
*/
@Override
- public void stop() throws Exception {
+ public void stop() {
super.stop();
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
index 8942cb7..488f030 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
@@ -155,11 +155,11 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
return answer;
}
- public void start() throws Exception {
+ public void start() {
id = null;
}
- public void stop() throws Exception {
+ public void stop() {
// need to clean up when we are stopping to not leak memory
if (synchronizations != null) {
synchronizations.clear();
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/InterceptSendToEndpointProcessor.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/InterceptSendToEndpointProcessor.java
index 48f551a..f14874c 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/InterceptSendToEndpointProcessor.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/InterceptSendToEndpointProcessor.java
@@ -120,13 +120,13 @@ public class InterceptSendToEndpointProcessor extends DefaultAsyncProducer {
return producer.isSingleton();
}
- public void start() throws Exception {
+ public void start() {
ServiceHelper.startService(endpoint.getDetour());
// here we also need to start the producer
ServiceHelper.startService(producer);
}
- public void stop() throws Exception {
+ public void stop() {
// do not stop detour as it should only be stopped when the interceptor stops
// we should stop the producer here
ServiceHelper.stopService(producer);
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/LimitedPollingConsumerPollStrategy.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/LimitedPollingConsumerPollStrategy.java
index 8f9a169..c16ae58 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/LimitedPollingConsumerPollStrategy.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/LimitedPollingConsumerPollStrategy.java
@@ -110,11 +110,11 @@ public class LimitedPollingConsumerPollStrategy extends DefaultPollingConsumerPo
return false;
}
- public void start() throws Exception {
+ public void start() {
// noop
}
- public void stop() throws Exception {
+ public void stop() {
state.clear();
}
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java
index 08fdce4..d34e170 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java
@@ -78,7 +78,7 @@ public class MDCUnitOfWork extends DefaultUnitOfWork {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
super.stop();
// and remove when stopping
clear();
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/ProvisionalEndpointRegistry.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/ProvisionalEndpointRegistry.java
index 4426c3e..61e37e2 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/ProvisionalEndpointRegistry.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/ProvisionalEndpointRegistry.java
@@ -29,12 +29,12 @@ import org.apache.camel.support.LRUCacheFactory;
class ProvisionalEndpointRegistry extends HashMap<EndpointKey, Endpoint> implements EndpointRegistry<EndpointKey> {
@Override
- public void start() throws Exception {
+ public void start() {
// noop
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// noop
}
diff --git a/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/DefaultRuntimeCamelCatalog.java b/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/DefaultRuntimeCamelCatalog.java
index fb8ba34..03a8df1 100644
--- a/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/DefaultRuntimeCamelCatalog.java
+++ b/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/DefaultRuntimeCamelCatalog.java
@@ -52,12 +52,12 @@ public class DefaultRuntimeCamelCatalog extends AbstractCamelCatalog implements
}
@Override
- public void start() throws Exception {
+ public void start() {
// noop
}
@Override
- public void stop() throws Exception {
+ public void stop() {
cache.clear();
}
diff --git a/core/camel-caffeine-lrucache/src/test/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheTest.java b/core/camel-caffeine-lrucache/src/test/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheTest.java
index 8e523a3..fea99e7 100644
--- a/core/camel-caffeine-lrucache/src/test/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheTest.java
+++ b/core/camel-caffeine-lrucache/src/test/java/org/apache/camel/component/caffeine/lrucache/CaffeineLRUCacheTest.java
@@ -154,10 +154,10 @@ public class CaffeineLRUCacheTest {
private Boolean stopped;
- public void start() throws Exception {
+ public void start() {
}
- public void stop() throws Exception {
+ public void stop() {
stopped = true;
}
diff --git a/core/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiBeanRepository.java b/core/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiBeanRepository.java
index 650880b..b66ae3a 100644
--- a/core/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiBeanRepository.java
+++ b/core/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiBeanRepository.java
@@ -135,12 +135,12 @@ public class OsgiBeanRepository extends LifecycleStrategySupport implements Bean
}
@Override
- public void start() throws Exception {
+ public void start() {
// noop
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// Unget the OSGi service as OSGi uses reference counting
// and we should do this as one of the last actions when stopping Camel
this.serviceReferenceUsageMap.forEach(this::drainServiceUsage);
diff --git a/core/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/test/MockTypeConverterRegistry.java b/core/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/test/MockTypeConverterRegistry.java
index 2dd0b06..b59d8a7 100644
--- a/core/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/test/MockTypeConverterRegistry.java
+++ b/core/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/test/MockTypeConverterRegistry.java
@@ -112,11 +112,11 @@ public class MockTypeConverterRegistry implements TypeConverterRegistry {
return null;
}
- public void start() throws Exception {
+ public void start() {
// noop
}
- public void stop() throws Exception {
+ public void stop() {
// noop
}
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
index 2809e31..cbe9310 100644
--- a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
+++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
@@ -133,12 +133,12 @@ public class SimpleLanguage extends LanguageSupport implements StaticService {
}
@Override
- public void start() throws Exception {
+ public void start() {
// noop
}
@Override
- public void stop() throws Exception {
+ public void stop() {
if (cachePredicate instanceof LRUCache) {
if (LOG.isDebugEnabled()) {
LRUCache cache = (LRUCache) cachePredicate;
diff --git a/core/camel-core/src/test/java/org/apache/camel/SuspendableServiceTest.java b/core/camel-core/src/test/java/org/apache/camel/SuspendableServiceTest.java
index 2608f7b..7b14f64 100644
--- a/core/camel-core/src/test/java/org/apache/camel/SuspendableServiceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/SuspendableServiceTest.java
@@ -25,10 +25,10 @@ public class SuspendableServiceTest extends Assert {
private boolean suspended;
- public void start() throws Exception {
+ public void start() {
}
- public void stop() throws Exception {
+ public void stop() {
}
public void suspend() {
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java
index e1f67c5..5cbd741 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.bean;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -54,7 +53,7 @@ public class BeanInvokeStaticTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
assertEquals("Static method with name: doSomething not found on class: org.apache.camel.component.bean.MyStaticClass", e.getCause().getCause().getMessage());
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanLifecycleTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanLifecycleTest.java
index 72c532f..5ab56d7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanLifecycleTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanLifecycleTest.java
@@ -107,12 +107,12 @@ public class BeanLifecycleTest extends ContextTestSupport {
}
@Override
- public void start() throws Exception {
+ public void start() {
status = "started";
}
@Override
- public void stop() throws Exception {
+ public void stop() {
status = "stopped";
}
}
@@ -124,12 +124,12 @@ public class BeanLifecycleTest extends ContextTestSupport {
}
@Override
- public void start() throws Exception {
+ public void start() {
fail("Should not be invoked");
}
@Override
- public void stop() throws Exception {
+ public void stop() {
fail("Should not be invoked");
}
}
@@ -146,11 +146,11 @@ public class BeanLifecycleTest extends ContextTestSupport {
}
@Override
- public void start() throws Exception {
+ public void start() {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
}
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
index 8cb041d..a1c40f96 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
@@ -44,8 +44,9 @@ public class BeanRefMethodNotFoundTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
- assertEquals("b", e.getRouteId());
+ } catch (Exception e) {
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ assertEquals("b", failed.getRouteId());
MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
assertEquals("bye", cause.getMethodName());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
index efdfa89..da4c26d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
@@ -45,9 +45,10 @@ public class BeanRefNotFoundTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
- assertEquals("b", e.getRouteId());
- NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ assertEquals("b", failed.getRouteId());
+ NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause().getCause());
assertEquals("bar", cause.getName());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java
index d4575f1..32ef478 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java
@@ -22,7 +22,6 @@ import org.apache.camel.CamelExecutionException;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.jndi.JndiContext;
@@ -102,7 +101,7 @@ public class BeanWithMethodHeaderTest extends ContextTestSupport {
}
});
fail("Should throw an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
assertEquals("ups", mnfe.getMethodName());
assertSame(bean, mnfe.getBean());
@@ -120,7 +119,7 @@ public class BeanWithMethodHeaderTest extends ContextTestSupport {
}
});
fail("Should throw an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
assertEquals("ups", mnfe.getMethodName());
assertSame(myBean, mnfe.getBean());
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/ClassComponentInvalidConfigurationTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/ClassComponentInvalidConfigurationTest.java
index f0d552c..bce40a4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/ClassComponentInvalidConfigurationTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/ClassComponentInvalidConfigurationTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.bean;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -42,7 +41,7 @@ public class ClassComponentInvalidConfigurationTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
ClassNotFoundException not = assertIsInstanceOf(ClassNotFoundException.class, cause.getCause());
assertEquals("org.apache.camel.component.bean.XXX", not.getMessage());
@@ -62,7 +61,7 @@ public class ClassComponentInvalidConfigurationTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
assertTrue(cause.getMessage().contains("Unknown parameters"));
assertTrue(cause.getMessage().contains("foo=bar"));
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
index 9a2fcd8..60b7042 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
@@ -44,8 +44,9 @@ public class MethodCallBeanRefMethodNotFoundTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
- assertEquals("b", e.getRouteId());
+ } catch (Exception e) {
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ assertEquals("b", failed.getRouteId());
MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
assertEquals("bye", cause.getMethodName());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
index ebe3ae7..cc2ef4a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
@@ -45,9 +45,10 @@ public class MethodCallBeanRefNotFoundTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
- assertEquals("b", e.getRouteId());
- NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ assertEquals("b", failed.getRouteId());
+ NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause().getCause());
assertEquals("bar", cause.getName());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
index 5c4239c..f5d4cf9 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.support.DefaultEndpoint;
import org.apache.camel.support.DefaultExchange;
@@ -81,15 +82,19 @@ public class DataSetTestEndpointTest extends ContextTestSupport {
}
@Override
- public void start() throws Exception {
+ public void start() {
// when starting then send a message to the processor
Exchange exchange = new DefaultExchange(getEndpoint());
exchange.getIn().setBody(expectedBody);
- processor.process(exchange);
+ try {
+ processor.process(exchange);
+ } catch (Exception e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// noop
}
};
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java b/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java
index 43ba51c..e6706f3f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.direct;
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
@@ -44,7 +43,7 @@ public class DirectNoMultipleConsumersTest extends TestSupport {
try {
container.start();
fail("Should have thrown an FailedToStartRouteException");
- } catch (FailedToStartRouteException e) {
+ } catch (Exception e) {
// expected
} finally {
container.stop();
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java
index e7f68b2..d0deff0 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java
@@ -135,16 +135,16 @@ public class FileConsumerCustomSchedulerTest extends ContextTestSupport {
}
@Override
- public void shutdown() throws Exception {
+ public void shutdown() {
timerTask.cancel();
}
@Override
- public void start() throws Exception {
+ public void start() {
}
@Override
- public void stop() throws Exception {
+ public void stop() {
}
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java
index a131cb3..e9fc5a4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java
@@ -112,10 +112,10 @@ public class FileConsumerIdempotentRefTest extends ContextTestSupport {
return;
}
- public void start() throws Exception {
+ public void start() {
}
- public void stop() throws Exception {
+ public void stop() {
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/properties/OptionalPropertiesDslInvalidSyntaxTest.java b/core/camel-core/src/test/java/org/apache/camel/component/properties/OptionalPropertiesDslInvalidSyntaxTest.java
index 88488e7..127c323 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/properties/OptionalPropertiesDslInvalidSyntaxTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/properties/OptionalPropertiesDslInvalidSyntaxTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.properties;
import org.apache.camel.CamelContext;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -40,7 +39,7 @@ public class OptionalPropertiesDslInvalidSyntaxTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Property with key [xxx] not found in properties from text: {{xxx}}", cause.getMessage());
}
@@ -59,7 +58,7 @@ public class OptionalPropertiesDslInvalidSyntaxTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("No setter to set property: xxx to: true on: Multicast[[To[mock:a], ThrowException[java.lang.IllegalAccessException], To[mock:b]]]", cause.getMessage());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentDefaultTest.java b/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentDefaultTest.java
index fe68a36..34b6432 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentDefaultTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentDefaultTest.java
@@ -20,7 +20,6 @@ import java.io.FileNotFoundException;
import java.io.IOError;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
@@ -56,7 +55,7 @@ public class PropertiesComponentDefaultTest extends ContextTestSupport {
try {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
RuntimeCamelException rce = assertIsInstanceOf(RuntimeCamelException.class, cause.getCause());
FileNotFoundException fnfe = assertIsInstanceOf(FileNotFoundException.class, rce.getCause());
@@ -136,7 +135,7 @@ public class PropertiesComponentDefaultTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertEquals("Cannot find JVM system property with key: my.home", e.getCause().getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnlyUseDefaultValuesTest.java b/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnlyUseDefaultValuesTest.java
index 210f9dc..0e5fe5a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnlyUseDefaultValuesTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnlyUseDefaultValuesTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.properties;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -62,7 +61,7 @@ public class PropertiesComponentOnlyUseDefaultValuesTest extends ContextTestSupp
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
// expected
}
}
@@ -81,7 +80,7 @@ public class PropertiesComponentOnlyUseDefaultValuesTest extends ContextTestSupp
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
// expected
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java b/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java
index 67ed228..7383265 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.properties;
import org.apache.camel.CamelContext;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -213,7 +212,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
try {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Property with key [foo.unknown] not found in properties from text: {{foo.unknown}}", iae.getMessage());
@@ -231,7 +230,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
try {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Circular reference detected with key [cool.a] from text: {{cool.a}}", iae.getMessage());
@@ -366,7 +365,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Property with key [cool.doesnotexist] (and original key [doesnotexist]) not found in properties from text: {{doesnotexist}}", iae.getMessage());
@@ -391,7 +390,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Property with key [cool.cool.end] not found in properties from text: {{cool.end}}", iae.getMessage());
@@ -455,7 +454,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Property with key [cool.end.end] not found in properties from text: {{cool.end}}", iae.getMessage());
@@ -473,7 +472,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
});
context.start();
fail("Should thrown an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Cannot find JVM system property with key: xxx", cause.getMessage());
}
@@ -590,7 +589,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertEquals("Property with key [beer] not found in properties from text: mock:{{beer}}", e.getCause().getMessage());
}
@@ -681,7 +680,7 @@ public class PropertiesComponentTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertEquals("Property with key [UNKNOWN] not found in properties from text: mock:{{UNKNOWN}}", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
index 3faaf62..dca1826 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
@@ -56,9 +56,10 @@ public class SameSedaQueueMultipleConsumersDifferenceTest extends ContextTestSup
}
});
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
- assertEquals("fail", e.getRouteId());
- assertEquals("Cannot use existing queue seda://foo as the existing queue multiple consumers true does not match given multiple consumers false", e.getCause().getMessage());
+ } catch (Exception e) {
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ assertEquals("fail", failed.getRouteId());
+ assertEquals("Cannot use existing queue seda://foo as the existing queue multiple consumers true does not match given multiple consumers false", e.getCause().getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullInvalidConfigurationTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullInvalidConfigurationTest.java
index c693923..1370425 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullInvalidConfigurationTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullInvalidConfigurationTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.seda;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -41,7 +40,7 @@ public class SedaBlockWhenFullInvalidConfigurationTest extends ContextTestSuppor
try {
context.start();
fail("Should fail");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
ResolveEndpointFailedException refe = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
assertEquals("Value [true, true] converted to java.lang.Boolean cannot be null", refe.getCause().getMessage());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
index c926442..c968e46 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
@@ -21,7 +21,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
@@ -202,7 +201,7 @@ public class TimerWithTimeOptionTest extends ContextTestSupport {
try {
context.start();
fail("Should throw an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertIsInstanceOf(ParseException.class, e.getCause().getCause());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIllegalImportTest.java b/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIllegalImportTest.java
index b157afc..64ebd7a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIllegalImportTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIllegalImportTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.validator;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -82,7 +81,7 @@ public class ValidatorIllegalImportTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertTrue(iae.getMessage().startsWith("Resource: org/apache/camel/component/validator/BroadcastMonitor.xsd refers an invalid resource without SystemId."));
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
index e3990c4..9052d31 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.xslt;
import javax.xml.transform.TransformerConfigurationException;
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
@@ -39,7 +38,7 @@ public class InvalidXsltFileTest extends TestSupport {
context.start();
fail("Should have thrown an exception due XSL compilation error");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
// expected
assertIsInstanceOf(TransformerConfigurationException.class, e.getCause());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java
index 15ee5a6..a396f95 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java
@@ -20,7 +20,6 @@ import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
@@ -77,7 +76,7 @@ public class XsltCustomErrorListenerTest extends TestSupport {
context.start();
fail("Should have thrown an exception due XSLT file not found");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
// expected
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
index d25b92b..86d623c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
@@ -21,7 +21,6 @@ import java.io.FileNotFoundException;
import javax.xml.transform.TransformerException;
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
@@ -41,7 +40,7 @@ public class XsltFileNotFoundTest extends TestSupport {
context.start();
fail("Should have thrown an exception due XSLT file not found");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertIsInstanceOf(TransformerException.class, e.getCause());
assertIsInstanceOf(FileNotFoundException.class, e.getCause().getCause());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltRouteXsltWithErrorTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltRouteXsltWithErrorTest.java
index 98f3533..e6cddb7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltRouteXsltWithErrorTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltRouteXsltWithErrorTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.xslt;
import javax.xml.transform.TransformerConfigurationException;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.util.ObjectHelper;
import org.junit.Test;
@@ -43,7 +42,7 @@ public class XsltRouteXsltWithErrorTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
TransformerConfigurationException cause = ObjectHelper.getException(TransformerConfigurationException.class, e);
assertNotNull(cause);
// not sure if XSLT errors may be i18n and not english always so just check for the spelling mistake of select -> slect
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java
index eb2d0e8..ef829ff 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.xslt;
import org.apache.camel.CamelContext;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
@@ -37,7 +36,7 @@ public class XsltSaxonTest extends TestSupport {
context.start();
fail("Should have thrown an exception due XSLT saxon not on classpath");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertIsInstanceOf(ClassNotFoundException.class, e.getCause());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextStopFailureTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextStopFailureTest.java
index fe21ac9..c84104d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextStopFailureTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextStopFailureTest.java
@@ -53,10 +53,10 @@ public class DefaultCamelContextStopFailureTest extends ContextTestSupport {
this.fail = fail;
}
- public void start() throws Exception {
+ public void start() {
}
- public void stop() throws Exception {
+ public void stop() {
stopOrder = stopOrder + name;
if (fail) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java
index b49496c..a3dad8e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java
@@ -40,9 +40,10 @@ public class FromHasNoOutputRouteTest extends ContextTestSupport {
try {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
- assertEquals("route1", e.getRouteId());
- IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ assertEquals("route1", failed.getRouteId());
+ IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Route route1 has no output processors. You need to add outputs to the route such as to(\"log:foo\").", cause.getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
index 034c746..13ed47f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.impl;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -40,9 +39,9 @@ public class GracefulShutdownNoAutoStartOrderClashTest extends ContextTestSuppor
try {
context.start();
fail("Should have thrown an exception");
- } catch (FailedToStartRouteException e) {
+ } catch (Exception e) {
assertEquals("Failed to start route bar because of startupOrder clash. Route foo already has startupOrder 5 configured"
- + " which this route have as well. Please correct startupOrder to be unique among all your routes.", e.getMessage());
+ + " which this route have as well. Please correct startupOrder to be unique among all your routes.", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyServiceTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyServiceTest.java
index 5cd3aa1..2cc0072 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyServiceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyServiceTest.java
@@ -48,12 +48,12 @@ public class LifecycleStrategyServiceTest extends TestSupport {
private volatile boolean started;
@Override
- public void start() throws Exception {
+ public void start() {
started = true;
}
@Override
- public void stop() throws Exception {
+ public void stop() {
started = false;
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
index 802695a..8237e05 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.impl;
import org.apache.camel.Consumer;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.MultipleConsumersSupport;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
@@ -53,8 +52,8 @@ public class MultipleConsumersSupportTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToStartRouteException e) {
- assertTrue(e.getMessage().endsWith("Multiple consumers for the same endpoint is not allowed: my:endpoint"));
+ } catch (Exception e) {
+ assertTrue(e.getCause().getMessage().endsWith("Multiple consumers for the same endpoint is not allowed: my:endpoint"));
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java
index beed1bc..4569c34 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.impl;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -72,7 +71,7 @@ public class RouteMustHaveOutputOnExceptionTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
// expected
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
index 361071b..48d2eb1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
@@ -29,9 +29,10 @@ public class RouteNoOutputTest extends ContextTestSupport {
try {
super.setUp();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
- assertEquals("route1", e.getRouteId());
- assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ } catch (Exception e) {
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ assertEquals("route1", failed.getRouteId());
+ assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Route route1 has no output processors. You need to add outputs to the route such as to(\"log:foo\").", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/event/EventNotifierServiceStoppingFailedEventTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/event/EventNotifierServiceStoppingFailedEventTest.java
index ab1f839..c3ca1b6 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/event/EventNotifierServiceStoppingFailedEventTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/event/EventNotifierServiceStoppingFailedEventTest.java
@@ -84,10 +84,10 @@ public class EventNotifierServiceStoppingFailedEventTest extends ContextTestSupp
this.fail = fail;
}
- public void start() throws Exception {
+ public void start() {
}
- public void stop() throws Exception {
+ public void stop() {
stopOrder = stopOrder + name;
if (fail) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java b/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java
index e084731..74dd08e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java
@@ -21,7 +21,6 @@ import java.util.Map;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.ExpressionIllegalSyntaxException;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.bean.MethodNotFoundException;
@@ -41,7 +40,7 @@ public class BeanLanguageInvalidOGNLTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
RuntimeCamelException rce = assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, rce.getCause());
assertEquals("getOther[xx", mnfe.getMethodName());
diff --git a/core/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java b/core/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java
index 29fa6c0..6b93a3c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.model;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -35,7 +34,7 @@ public class ProcessorTypeConfigurationTest extends ContextTestSupport {
}
});
fail("Should have thrown IllegalArgumentException");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertEquals("No bean could be found in the registry for: hello of type: org.apache.camel.Processor", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java b/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java
index 6067758..d84f201 100644
--- a/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/model/RoutePropertiesTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.model;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.Route;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -71,7 +70,7 @@ public class RoutePropertiesTest extends ContextTestSupport {
context.start();
fail("");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
}
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java b/core/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
index cec98ba..e93e80e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/model/StartingRoutesErrorReportedTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.model;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -34,7 +33,7 @@ public class StartingRoutesErrorReportedTest extends ContextTestSupport {
});
context.start();
fail();
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getMessage().startsWith("Failed to create route route1: Route(route1)[From[direct:start?foo=bar] -> [To[mock:result]... because of"));
}
}
@@ -50,7 +49,7 @@ public class StartingRoutesErrorReportedTest extends ContextTestSupport {
});
context.start();
fail();
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getMessage().startsWith("Failed to create route route2 at: >>> To[direct:result?foo=bar] <<< in route:"));
}
}
@@ -66,7 +65,7 @@ public class StartingRoutesErrorReportedTest extends ContextTestSupport {
});
context.start();
fail();
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getMessage().startsWith("Failed to create route route2 at: >>> To[direct:result?foo=bar] <<< in route:"));
}
}
@@ -84,7 +83,7 @@ public class StartingRoutesErrorReportedTest extends ContextTestSupport {
});
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getMessage().startsWith("Failed to create route route3 at: >>> Bean[ref:] <<< in route:"));
}
}
@@ -102,7 +101,7 @@ public class StartingRoutesErrorReportedTest extends ContextTestSupport {
});
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getMessage().contains("Ensure that the data format is valid and the associated Camel component is present on the classpath"));
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/CreateRouteWithNonExistingEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/CreateRouteWithNonExistingEndpointTest.java
index 3ef3da7..f8b286a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/CreateRouteWithNonExistingEndpointTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/CreateRouteWithNonExistingEndpointTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Before;
@@ -34,7 +33,7 @@ public class CreateRouteWithNonExistingEndpointTest extends ContextTestSupport {
try {
super.setUp();
fail("Should have failed to create this route!");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
log.debug("Caught expected exception: " + e, e);
NoSuchEndpointException nse = assertIsInstanceOf(NoSuchEndpointException.class, e.getCause());
assertEquals("uri", "thisUriDoesNotExist", nse.getUri());
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ExchangeIdempotentConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ExchangeIdempotentConsumerTest.java
index 771358c..d8a37e6 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ExchangeIdempotentConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ExchangeIdempotentConsumerTest.java
@@ -159,12 +159,12 @@ public class ExchangeIdempotentConsumerTest extends ContextTestSupport {
}
@Override
- public void start() throws Exception {
+ public void start() {
// noop
}
@Override
- public void stop() throws Exception {
+ public void stop() {
// noop
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerUsingCustomRepositoryTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerUsingCustomRepositoryTest.java
index e522f50..a58c8f2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerUsingCustomRepositoryTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerUsingCustomRepositoryTest.java
@@ -131,11 +131,11 @@ public class IdempotentConsumerUsingCustomRepositoryTest extends ContextTestSupp
return true;
}
- public void start() throws Exception {
+ public void start() {
// noop
}
- public void stop() throws Exception {
+ public void stop() {
// noop
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/NewProcessorAndServiceTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/NewProcessorAndServiceTest.java
index 9dfe5a1..3c430df 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/NewProcessorAndServiceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/NewProcessorAndServiceTest.java
@@ -53,11 +53,11 @@ public class NewProcessorAndServiceTest extends ContextTestSupport {
exchange.getOut().setBody("Bye World");
}
- public void start() throws Exception {
+ public void start() {
started = true;
}
- public void stop() throws Exception {
+ public void stop() {
started = false;
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RouteStartupOrderClashTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/RouteStartupOrderClashTest.java
index 7166a4d..0c5e49a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RouteStartupOrderClashTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/RouteStartupOrderClashTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -45,7 +44,7 @@ public class RouteStartupOrderClashTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown an exception");
- } catch (FailedToStartRouteException e) {
+ } catch (Exception e) {
// expected
assertTrue(e.getMessage().contains("startupOrder 2"));
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RouteWithConstantFieldFromExchangeFailTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/RouteWithConstantFieldFromExchangeFailTest.java
index 007a1ea..669aeef 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RouteWithConstantFieldFromExchangeFailTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/RouteWithConstantFieldFromExchangeFailTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Before;
import org.junit.Test;
@@ -34,7 +33,7 @@ public class RouteWithConstantFieldFromExchangeFailTest extends ContextTestSuppo
try {
super.setUp();
fail("Should have thrown an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Constant field with name: XXX not found on Exchange.class", iae.getMessage());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
index f29a5a1..0f67611 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -41,7 +40,7 @@ public class ThreadsCoreAndMaxPoolInvalidTest extends ContextTestSupport {
});
fail("Should have thrown an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("MaxPoolSize must be >= corePoolSize, was 2 >= 5", iae.getMessage());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java
index a0900a3..0c1dd16 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spi.ThreadPoolProfile;
import org.junit.Test;
@@ -53,7 +52,7 @@ public class ThreadsInvalidConfigTest extends ContextTestSupport {
.to("mock:test");
}
});
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertTrue(e.getCause().getMessage().startsWith("ThreadName"));
return;
@@ -86,7 +85,7 @@ public class ThreadsInvalidConfigTest extends ContextTestSupport {
.to("mock:test");
}
});
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertTrue(e.getCause().getMessage().startsWith("PoolSize"));
return;
@@ -106,7 +105,7 @@ public class ThreadsInvalidConfigTest extends ContextTestSupport {
.to("mock:test");
}
});
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertTrue(e.getCause().getMessage().startsWith("MaxPoolSize"));
return;
@@ -126,7 +125,7 @@ public class ThreadsInvalidConfigTest extends ContextTestSupport {
.to("mock:test");
}
});
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertTrue(e.getCause().getMessage().startsWith("KeepAliveTime"));
return;
@@ -146,7 +145,7 @@ public class ThreadsInvalidConfigTest extends ContextTestSupport {
.to("mock:test");
}
});
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertTrue(e.getCause().getMessage().startsWith("MaxQueueSize"));
return;
@@ -166,7 +165,7 @@ public class ThreadsInvalidConfigTest extends ContextTestSupport {
.to("mock:test");
}
});
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertTrue(e.getCause() instanceof IllegalArgumentException);
assertTrue(e.getCause().getMessage().startsWith("RejectedPolicy"));
return;
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
index 0620e47..e136a4e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -44,7 +43,7 @@ public class ThreadsZeroInCoreAndMaxPoolTest extends ContextTestSupport {
}
});
fail("Expect FailedToCreateRouteException exception here");
- } catch (FailedToCreateRouteException ex) {
+ } catch (Exception ex) {
assertTrue(ex.getCause() instanceof IllegalArgumentException);
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerInvalidConfiguredTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerInvalidConfiguredTest.java
index c01ad1e..fa7ffed 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerInvalidConfiguredTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerInvalidConfiguredTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -35,7 +34,7 @@ public class ThrottlerInvalidConfiguredTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertTrue(cause.getMessage().startsWith("MaxRequestsPerPeriod expression must be provided"));
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/TryCatchMustHaveExceptionConfiguredTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/TryCatchMustHaveExceptionConfiguredTest.java
index 253a15c..048ed23 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/TryCatchMustHaveExceptionConfiguredTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/TryCatchMustHaveExceptionConfiguredTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -42,7 +41,7 @@ public class TryCatchMustHaveExceptionConfiguredTest extends ContextTestSupport
try {
context.start();
fail("Should throw exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("At least one Exception must be configured to catch", e.getCause().getMessage());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
index 7c1f42f..4d09486 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
@@ -124,7 +123,7 @@ public class WeightedRandomLoadBalanceTest extends ContextTestSupport {
});
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Loadbalacing with 3 should match number of distributions 2", iae.getMessage());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java
index a623aa6..7dd0b52 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRoundRobinLoadBalanceTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
@@ -130,7 +129,7 @@ public class WeightedRoundRobinLoadBalanceTest extends ContextTestSupport {
});
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Loadbalacing with 3 should match number of distributions 2", iae.getMessage());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
index ea35371..3c1f8c2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.processor.onexception;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -45,7 +44,7 @@ public class OnExceptionHandledAndContinueTest extends ContextTestSupport {
try {
context.start();
fail("Should thrown an exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertTrue(e.getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
index f03bb23..a56cab4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import javax.xml.soap.SOAPException;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -48,7 +47,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
@@ -67,7 +66,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
@@ -87,7 +86,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
@@ -107,7 +106,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
@@ -128,7 +127,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
try {
context.start();
fail("Should have thrown exception");
- } catch (FailedToCreateRouteException e) {
+ } catch (Exception e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertTrue(iae.getMessage().startsWith("At least one exception must be configured"));
}
diff --git a/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java b/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java
index de9f49a..ceed5c0 100644
--- a/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java
+++ b/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.management;
-import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
@@ -50,8 +49,8 @@ public class ManagedDuplicateIdTest extends ManagementTestSupport {
try {
context.start();
fail("Should fail");
- } catch (FailedToStartRouteException e) {
- assertEquals("Failed to start route foo because of duplicate id detected: clash. Please correct ids to be unique among all your routes.", e.getMessage());
+ } catch (Exception e) {
+ assertEquals("Failed to start route foo because of duplicate id detected: clash. Please correct ids to be unique among all your routes.", e.getCause().getMessage());
}
}
diff --git a/core/camel-management-impl/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java b/core/camel-management-impl/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java
index ddca4dd..28daac1 100644
--- a/core/camel-management-impl/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java
+++ b/core/camel-management-impl/src/test/java/org/apache/camel/management/TwoManagedCamelContextClashTest.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
package org.apache.camel.management;
+
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.camel.CamelContext;
import org.apache.camel.TestSupport;
-import org.apache.camel.VetoCamelContextStartException;
import org.apache.camel.impl.DefaultCamelContext;
import org.junit.After;
import org.junit.Test;
@@ -107,8 +107,8 @@ public class TwoManagedCamelContextClashTest extends TestSupport {
try {
camel2.start();
fail("Should have thrown an exception");
- } catch (VetoCamelContextStartException e) {
- assertTrue(e.getMessage().contains("is already registered"));
+ } catch (Exception e) {
+ assertTrue(e.getCause().getMessage().contains("is already registered"));
}
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/AsyncProcessorConverterHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/AsyncProcessorConverterHelper.java
index c65a711..28fc11f 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/AsyncProcessorConverterHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/AsyncProcessorConverterHelper.java
@@ -100,11 +100,11 @@ public final class AsyncProcessorConverterHelper {
}
}
- public void start() throws Exception {
+ public void start() {
ServiceHelper.startService(processor);
}
- public void stop() throws Exception {
+ public void stop() {
ServiceHelper.stopService(processor);
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
index fdbc8eb..6f818ee 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
@@ -19,6 +19,7 @@ package org.apache.camel.support;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.Service;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.support.service.ServiceSupport;
@@ -30,7 +31,7 @@ public abstract class ChildServiceSupport extends ServiceSupport {
protected volatile List<Service> childServices;
- public void start() throws Exception {
+ public void start() {
synchronized (lock) {
if (status == STARTED) {
log.trace("Service: {} already started", this);
@@ -45,7 +46,7 @@ public abstract class ChildServiceSupport extends ServiceSupport {
} catch (Exception e) {
status = FAILED;
log.trace("Error while initializing service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
try {
status = STARTING;
@@ -58,12 +59,12 @@ public abstract class ChildServiceSupport extends ServiceSupport {
status = FAILED;
log.trace("Error while starting service: " + this, e);
ServiceHelper.stopService(childServices);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
- public void stop() throws Exception {
+ public void stop() {
synchronized (lock) {
if (status == STOPPED || status == SHUTTINGDOWN || status == SHUTDOWN) {
log.trace("Service: {} already stopped", this);
@@ -83,13 +84,13 @@ public abstract class ChildServiceSupport extends ServiceSupport {
} catch (Exception e) {
status = FAILED;
log.trace("Error while stopping service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
@Override
- public void shutdown() throws Exception {
+ public void shutdown() {
synchronized (lock) {
if (status == SHUTDOWN) {
log.trace("Service: {} already shut down", this);
@@ -110,7 +111,7 @@ public abstract class ChildServiceSupport extends ServiceSupport {
} catch (Exception e) {
status = FAILED;
log.trace("Error shutting down service: " + this, e);
- throw e;
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java b/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java
index 6531945..646de74 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/SynchronousDelegateProducer.java
@@ -19,6 +19,7 @@ package org.apache.camel.support;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Producer;
+import org.apache.camel.support.service.ServiceHelper;
/**
* To process the delegated producer in synchronous mode.
@@ -50,12 +51,12 @@ public class SynchronousDelegateProducer implements Producer {
producer.init();
}
- public void start() throws Exception {
- producer.start();
+ public void start() {
+ ServiceHelper.startService(producer);
}
- public void stop() throws Exception {
- producer.stop();
+ public void stop() {
+ ServiceHelper.stopService(producer);
}
public boolean isSingleton() {
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java b/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java
index 90df335..1a790be 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/management/MBeanInfoAssembler.java
@@ -64,13 +64,12 @@ public class MBeanInfoAssembler implements Service {
}
@Override
- @SuppressWarnings("unchecked")
- public void start() throws Exception {
+ public void start() {
cache = LRUCacheFactory.newLRUWeakCache(1000);
}
@Override
- public void stop() throws Exception {
+ public void stop() {
if (cache != null) {
if (LOG.isDebugEnabled() && cache instanceof LRUCache) {
LRUCache cache = (LRUCache) this.cache;
[camel] 07/11: CAMEL-13522: camel3 - The various Camel exceptions
should favour extending runtime exception
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8ae96e7c45ed8a7487ffb6485505d8456ad0a4cc
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 13:42:33 2019 +0200
CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
---
.../camel/component/bean/AmbiguousMethodCallException.java | 5 ++---
.../apache/camel/component/bean/MethodNotFoundException.java | 5 ++---
.../apache/camel/component/bean/ParameterBindingException.java | 1 -
.../java/org/apache/camel/FailedToStartRouteException.java | 8 ++++++++
.../apache/camel/component/bean/BeanRefMethodNotFoundTest.java | 2 +-
.../org/apache/camel/component/bean/BeanRefNotFoundTest.java | 4 ++--
.../component/bean/MethodCallBeanRefMethodNotFoundTest.java | 4 ++--
.../camel/component/bean/MethodCallBeanRefNotFoundTest.java | 4 ++--
.../directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java | 2 +-
.../seda/SameSedaQueueMultipleConsumersDifferenceTest.java | 8 +++-----
.../camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java | 2 +-
.../apache/camel/impl/LifecycleStrategyFailOnStartupTest.java | 2 +-
.../org/apache/camel/impl/MultipleConsumersSupportTest.java | 2 +-
.../src/test/java/org/apache/camel/impl/RouteNoOutputTest.java | 4 ++--
.../org/apache/camel/impl/engine/DefaultFactoryFinderTest.java | 2 +-
.../apache/camel/processor/WeightedRandomLoadBalanceTest.java | 3 ++-
.../aggregator/AggregateUnknownExecutorServiceRefTest.java | 2 +-
.../onexception/OnExceptionHandledAndContinueTest.java | 4 ++--
.../processor/onexception/OnExceptionMisconfiguredTest.java | 10 +++++-----
19 files changed, 39 insertions(+), 35 deletions(-)
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java
index c99c2f4..94a20a3 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AmbiguousMethodCallException.java
@@ -18,15 +18,14 @@ package org.apache.camel.component.bean;
import java.util.Collection;
-import org.apache.camel.CamelExchangeException;
import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeExchangeException;
/**
* An exception thrown if an attempted method invocation resulted in an ambiguous method
* such that multiple methods match the inbound message exchange
*/
-public class AmbiguousMethodCallException extends CamelExchangeException {
- private static final long serialVersionUID = -8867010485101806951L;
+public class AmbiguousMethodCallException extends RuntimeExchangeException {
private final Collection<MethodInfo> methods;
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java
index 1c7673c..c6a3aa6 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodNotFoundException.java
@@ -16,12 +16,11 @@
*/
package org.apache.camel.component.bean;
-import org.apache.camel.CamelExchangeException;
import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeExchangeException;
import org.apache.camel.util.ObjectHelper;
-public class MethodNotFoundException extends CamelExchangeException {
- private static final long serialVersionUID = -7411465307141051012L;
+public class MethodNotFoundException extends RuntimeExchangeException {
private final Object bean;
private final String methodName;
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java
index 70f31bb..4ff9831 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/ParameterBindingException.java
@@ -23,7 +23,6 @@ import org.apache.camel.util.ObjectHelper;
public class ParameterBindingException extends RuntimeCamelException {
- private static final long serialVersionUID = 1L;
private final Method method;
private final int index;
private final Class<?> parameterType;
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
index 35f3fff..f3195d1 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java
@@ -21,17 +21,25 @@ package org.apache.camel;
*/
public class FailedToStartRouteException extends RuntimeCamelException {
+ private String routeId;
+
public FailedToStartRouteException(String routeId, String message) {
super("Failed to start route " + routeId + " because of " + message);
+ this.routeId = routeId;
}
public FailedToStartRouteException(String routeId, String message, Throwable cause) {
super("Failed to start route " + routeId + " because of " + message, cause);
+ this.routeId = routeId;
}
public FailedToStartRouteException(Throwable cause) {
super(cause);
}
+
+ public String getRouteId() {
+ return routeId;
+ }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
index a1c40f96..f70a3cf 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
@@ -45,7 +45,7 @@ public class BeanRefMethodNotFoundTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertEquals("b", failed.getRouteId());
MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
assertEquals("bye", cause.getMethodName());
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
index da4c26d..414a019 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefNotFoundTest.java
@@ -46,9 +46,9 @@ public class BeanRefNotFoundTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertEquals("b", failed.getRouteId());
- NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause().getCause());
+ NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
assertEquals("bar", cause.getName());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
index 60b7042..d7b5fee 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefMethodNotFoundTest.java
@@ -45,9 +45,9 @@ public class MethodCallBeanRefMethodNotFoundTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertEquals("b", failed.getRouteId());
- MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
+ MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause());
assertEquals("bye", cause.getMethodName());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
index cc2ef4a..4cd58ea 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanRefNotFoundTest.java
@@ -46,9 +46,9 @@ public class MethodCallBeanRefNotFoundTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertEquals("b", failed.getRouteId());
- NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause().getCause());
+ NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
assertEquals("bar", cause.getName());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
index 1b37fe7..917d4af 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmTwoCamelContextDuplicateConsumerTest.java
@@ -35,7 +35,7 @@ public class DirectVmTwoCamelContextDuplicateConsumerTest extends AbstractDirect
third.start();
fail("Should have thrown exception");
} catch (Exception e) {
- assertEquals("A consumer Consumer[direct-vm://foo] already exists from CamelContext: camel-1. Multiple consumers not supported", e.getCause().getMessage());
+ assertEquals("A consumer Consumer[direct-vm://foo] already exists from CamelContext: camel-1. Multiple consumers not supported", e.getMessage());
}
// stop first camel context then
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
index dca1826..d036902 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueMultipleConsumersDifferenceTest.java
@@ -18,12 +18,10 @@ package org.apache.camel.component.seda;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
-/**
- *
- */
public class SameSedaQueueMultipleConsumersDifferenceTest extends ContextTestSupport {
@Test
@@ -57,9 +55,9 @@ public class SameSedaQueueMultipleConsumersDifferenceTest extends ContextTestSup
});
fail("Should have thrown exception");
} catch (Exception e) {
- FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ FailedToStartRouteException failed = assertIsInstanceOf(FailedToStartRouteException.class, e);
assertEquals("fail", failed.getRouteId());
- assertEquals("Cannot use existing queue seda://foo as the existing queue multiple consumers true does not match given multiple consumers false", e.getCause().getCause().getMessage());
+ assertEquals("Cannot use existing queue seda://foo as the existing queue multiple consumers true does not match given multiple consumers false", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
index 13ed47f..bbb8298 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/GracefulShutdownNoAutoStartOrderClashTest.java
@@ -41,7 +41,7 @@ public class GracefulShutdownNoAutoStartOrderClashTest extends ContextTestSuppor
fail("Should have thrown an exception");
} catch (Exception e) {
assertEquals("Failed to start route bar because of startupOrder clash. Route foo already has startupOrder 5 configured"
- + " which this route have as well. Please correct startupOrder to be unique among all your routes.", e.getCause().getMessage());
+ + " which this route have as well. Please correct startupOrder to be unique among all your routes.", e.getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
index 1c5d1f1..bdd6c4a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
@@ -39,7 +39,7 @@ public class LifecycleStrategyFailOnStartupTest extends TestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- assertEquals("Forced", e.getCause().getMessage());
+ assertEquals("Forced", e.getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
index 8237e05..7eec9d1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/MultipleConsumersSupportTest.java
@@ -53,7 +53,7 @@ public class MultipleConsumersSupportTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- assertTrue(e.getCause().getMessage().endsWith("Multiple consumers for the same endpoint is not allowed: my:endpoint"));
+ assertTrue(e.getMessage().endsWith("Multiple consumers for the same endpoint is not allowed: my:endpoint"));
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
index 48d2eb1..f545e8e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/RouteNoOutputTest.java
@@ -30,9 +30,9 @@ public class RouteNoOutputTest extends ContextTestSupport {
super.setUp();
fail("Should have thrown exception");
} catch (Exception e) {
- FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertEquals("route1", failed.getRouteId());
- assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Route route1 has no output processors. You need to add outputs to the route such as to(\"log:foo\").", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java
index f26cf24..0389d2d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultFactoryFinderTest.java
@@ -97,7 +97,7 @@ public class DefaultFactoryFinderTest {
factoryFinder.newInstance("TestImplX");
fail("NoFactoryAvailableException should have been thrown");
} catch (final NoFactoryAvailableException e) {
- assertEquals("Could not find factory class for resource: TestImplX", e.getMessage());
+ assertEquals("Cannot find factory class for resource: TestImplX", e.getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
index 4d09486..5d4de65 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/WeightedRandomLoadBalanceTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.processor;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -124,7 +125,7 @@ public class WeightedRandomLoadBalanceTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Loadbalacing with 3 should match number of distributions 2", iae.getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
index b9692e5..491a237 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateUnknownExecutorServiceRefTest.java
@@ -48,7 +48,7 @@ public class AggregateUnknownExecutorServiceRefTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertTrue(cause.getMessage().contains("myUnknownProfile"));
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
index 38c360c..3c1f8c2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledAndContinueTest.java
@@ -45,8 +45,8 @@ public class OnExceptionHandledAndContinueTest extends ContextTestSupport {
context.start();
fail("Should thrown an exception");
} catch (Exception e) {
- assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
- assertTrue(e.getCause().getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
+ assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ assertTrue(e.getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
index 6475f91..a56cab4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
@@ -48,7 +48,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -67,7 +67,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -87,7 +87,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -107,7 +107,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
@@ -128,7 +128,7 @@ public class OnExceptionMisconfiguredTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertTrue(iae.getMessage().startsWith("At least one exception must be configured"));
}
}
[camel] 08/11: CAMEL-13522: camel3 - The various Camel exceptions
should favour extending runtime exception
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 47447ba105b13dae9972812ffe168309df5431ae
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 15:11:30 2019 +0200
CAMEL-13522: camel3 - The various Camel exceptions should favour extending runtime exception
---
.../java/org/apache/camel/component/bean/BeanInvokeStaticTest.java | 5 ++---
.../org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java | 2 +-
.../org/apache/camel/component/bean/BeanWithMethodHeaderTest.java | 4 ++--
.../component/file/FileConsumerFileExpressionThrowExceptionTest.java | 2 +-
.../java/org/apache/camel/component/xslt/InvalidXsltFileTest.java | 2 +-
.../java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java | 4 ++--
.../src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java | 2 +-
.../test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java | 4 ++--
.../java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java | 2 +-
.../camel-core/src/test/java/org/apache/camel/language/BeanTest.java | 2 +-
.../java/org/apache/camel/management/ManagedDuplicateIdTest.java | 2 +-
11 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java
index 5cbd741..6826ad7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvokeStaticTest.java
@@ -54,9 +54,8 @@ public class BeanInvokeStaticTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
- assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
- assertEquals("Static method with name: doSomething not found on class: org.apache.camel.component.bean.MyStaticClass", e.getCause().getCause().getMessage());
+ assertIsInstanceOf(MethodNotFoundException.class, e.getCause());
+ assertEquals("Static method with name: doSomething not found on class: org.apache.camel.component.bean.MyStaticClass", e.getCause().getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
index f70a3cf..5f6acc8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanRefMethodNotFoundTest.java
@@ -47,7 +47,7 @@ public class BeanRefMethodNotFoundTest extends ContextTestSupport {
} catch (Exception e) {
FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertEquals("b", failed.getRouteId());
- MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
+ MethodNotFoundException cause = assertIsInstanceOf(MethodNotFoundException.class, e.getCause());
assertEquals("bye", cause.getMethodName());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java
index 32ef478..fe3f6e8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java
@@ -102,7 +102,7 @@ public class BeanWithMethodHeaderTest extends ContextTestSupport {
});
fail("Should throw an exception");
} catch (Exception e) {
- MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
+ MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause());
assertEquals("ups", mnfe.getMethodName());
assertSame(bean, mnfe.getBean());
}
@@ -120,7 +120,7 @@ public class BeanWithMethodHeaderTest extends ContextTestSupport {
});
fail("Should throw an exception");
} catch (Exception e) {
- MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
+ MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause());
assertEquals("ups", mnfe.getMethodName());
assertSame(myBean, mnfe.getBean());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java
index 5c2c81e..37ec5ba 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java
@@ -83,7 +83,7 @@ public class FileConsumerFileExpressionThrowExceptionTest extends ContextTestSup
assertNotNull(rollbackCause);
- MethodNotFoundException e = assertIsInstanceOf(MethodNotFoundException.class, rollbackCause.getCause());
+ MethodNotFoundException e = assertIsInstanceOf(MethodNotFoundException.class, rollbackCause);
assertNotNull(e);
assertEquals("doNotExistMethod", e.getMethodName());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
index 9052d31..41470ce 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
@@ -40,7 +40,7 @@ public class InvalidXsltFileTest extends TestSupport {
fail("Should have thrown an exception due XSL compilation error");
} catch (Exception e) {
// expected
- assertIsInstanceOf(TransformerConfigurationException.class, e.getCause());
+ assertIsInstanceOf(TransformerConfigurationException.class, e.getCause().getCause());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
index 86d623c..cf8617b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
@@ -41,8 +41,8 @@ public class XsltFileNotFoundTest extends TestSupport {
fail("Should have thrown an exception due XSLT file not found");
} catch (Exception e) {
- assertIsInstanceOf(TransformerException.class, e.getCause());
- assertIsInstanceOf(FileNotFoundException.class, e.getCause().getCause());
+ assertIsInstanceOf(TransformerException.class, e.getCause().getCause());
+ assertIsInstanceOf(FileNotFoundException.class, e.getCause().getCause().getCause());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java
index ef829ff..dee4088 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltSaxonTest.java
@@ -37,7 +37,7 @@ public class XsltSaxonTest extends TestSupport {
fail("Should have thrown an exception due XSLT saxon not on classpath");
} catch (Exception e) {
- assertIsInstanceOf(ClassNotFoundException.class, e.getCause());
+ assertIsInstanceOf(ClassNotFoundException.class, e.getCause().getCause());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java
index a3dad8e..4401578 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/FromHasNoOutputRouteTest.java
@@ -41,9 +41,9 @@ public class FromHasNoOutputRouteTest extends ContextTestSupport {
context.start();
fail("Should throw exception");
} catch (Exception e) {
- FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause());
+ FailedToCreateRouteException failed = assertIsInstanceOf(FailedToCreateRouteException.class, e);
assertEquals("route1", failed.getRouteId());
- IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
+ IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Route route1 has no output processors. You need to add outputs to the route such as to(\"log:foo\").", cause.getMessage());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java b/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java
index 74dd08e..f7c74da 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/BeanLanguageInvalidOGNLTest.java
@@ -41,7 +41,7 @@ public class BeanLanguageInvalidOGNLTest extends ContextTestSupport {
context.start();
fail("Should have thrown exception");
} catch (Exception e) {
- RuntimeCamelException rce = assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
+ RuntimeCamelException rce = assertIsInstanceOf(RuntimeCamelException.class, e);
MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, rce.getCause());
assertEquals("getOther[xx", mnfe.getMethodName());
ExpressionIllegalSyntaxException cause = assertIsInstanceOf(ExpressionIllegalSyntaxException.class, mnfe.getCause());
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/BeanTest.java b/core/camel-core/src/test/java/org/apache/camel/language/BeanTest.java
index f87e0bf..e97348e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/BeanTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/BeanTest.java
@@ -93,7 +93,7 @@ public class BeanTest extends LanguageTestSupport {
exp.evaluate(exchange, Object.class);
fail("Should throw exception");
} catch (Exception e) {
- MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause());
+ MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e);
assertSame(user, mnfe.getBean());
assertEquals("unknown", mnfe.getMethodName());
}
diff --git a/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java b/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java
index ceed5c0..cae4c3d 100644
--- a/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java
+++ b/core/camel-management-impl/src/test/java/org/apache/camel/management/ManagedDuplicateIdTest.java
@@ -50,7 +50,7 @@ public class ManagedDuplicateIdTest extends ManagementTestSupport {
context.start();
fail("Should fail");
} catch (Exception e) {
- assertEquals("Failed to start route foo because of duplicate id detected: clash. Please correct ids to be unique among all your routes.", e.getCause().getMessage());
+ assertEquals("Failed to start route foo because of duplicate id detected: clash. Please correct ids to be unique among all your routes.", e.getMessage());
}
}
[camel] 02/11: CAMEL-13501: Component should move initialization
logic to doInit instead of doStart
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch 13514
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 31ef818c3bfc516199fadb918a8dc46d6c0918c7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 14 09:42:01 2019 +0200
CAMEL-13501: Component should move initialization logic to doInit instead of doStart
---
core/camel-api/src/main/java/org/apache/camel/Service.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/Service.java b/core/camel-api/src/main/java/org/apache/camel/Service.java
index 89d3162..f601be4 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Service.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Service.java
@@ -17,12 +17,14 @@
package org.apache.camel;
/**
- * Represents the core lifecycle API for POJOs which can be started and stopped
+ * Represents the core lifecycle API for services which can be initialized, started and stopped
*/
public interface Service {
/**
* Initialize the service
+ *
+ * @throws RuntimeException is thrown if initialization failed
*/
default void init() {
}