You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/07/23 11:25:24 UTC

[1/2] git commit: CAMEL-6441: ServiceSupport when exception during starting, then ensure clear flags to being stopped state.

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 <da...@apache.org>
Authored: Tue Jul 23 11:22:12 2013 +0200
Committer: Claus Ibsen <da...@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");


[2/2] git commit: CAMEL-6441: ServiceSupport when exception during starting, then ensure clear flags to being stopped state.

Posted by da...@apache.org.
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/0f1fc14f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0f1fc14f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0f1fc14f

Branch: refs/heads/camel-2.10.x
Commit: 0f1fc14fb0aee3c91d214217eb4673b66b1cf728
Parents: 224b675
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 11:22:12 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 11:25:00 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/0f1fc14f/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 fac814a..490ee00 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/0f1fc14f/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 2485bc5..a739f9c 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");