This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit f43cad72917569955b5a4c09b2523b42d14995e2 Author: Claus Ibsen <claus.ib...@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;