Updated Branches: refs/heads/camel-2.10.x 224b675a6 -> 0f1fc14fb refs/heads/camel-2.11.x 736db12a2 -> d2f7f3967
CAMEL-6441: ServiceSupport when exception during starting, then ensure clear flags to being stopped state. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d2f7f396 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d2f7f396 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d2f7f396 Branch: refs/heads/camel-2.11.x Commit: d2f7f39677787567197c12c7680106e16a424e7f Parents: 736db12 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Jul 23 11:22:12 2013 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jul 23 11:24:45 2013 +0200 ---------------------------------------------------------------------- .../java/org/apache/camel/support/ServiceSupport.java | 10 ++++++++++ .../java/org/apache/camel/support/ServiceSupportTest.java | 7 +++++++ 2 files changed, 17 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d2f7f396/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java b/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java index 85864c0..76515e6 100644 --- a/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java +++ b/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java @@ -72,6 +72,16 @@ public abstract class ServiceSupport implements StatefulService { stop(); } catch (Exception e2) { // Ignore exceptions as we want to show the original exception + } finally { + // ensure flags get reset to stopped as we failed during starting + stopping.set(false); + stopped.set(true); + starting.set(false); + started.set(false); + suspending.set(false); + suspended.set(false); + shutdown.set(false); + shuttingdown.set(false); } throw e; } http://git-wip-us.apache.org/repos/asf/camel/blob/d2f7f396/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java b/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java index 9d87389..efe8a04 100644 --- a/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java +++ b/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java @@ -93,6 +93,8 @@ public class ServiceSupportTest extends TestSupport { public void testExceptionOnStart() throws Exception { ServiceSupportTestExOnStart service = new ServiceSupportTestExOnStart(); + // forced not being stopped at start + assertEquals(false, service.isStopped()); try { service.start(); fail("RuntimeException expected"); @@ -106,6 +108,11 @@ public class ServiceSupportTest extends TestSupport { public static class ServiceSupportTestExOnStart extends ServiceSupport { + public ServiceSupportTestExOnStart() { + // just for testing force it to not be stopped + stopped.set(false); + } + @Override protected void doStart() throws Exception { throw new RuntimeException("This service throws an exception when starting");