[ https://issues.apache.org/jira/browse/CAMEL-4381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13093492#comment-13093492 ]
Claus Ibsen commented on CAMEL-4381: ------------------------------------ Spotted another issue, in the ServiceSupport. The start/stop methods etc. when an exception is thrown from doStart,doStop, then the state of the service should be "changed back" etc. So if a service is attempted to be started and it fails, then the old logic ensured the state would be as stopped. Now the logic doesnt do that. For example the "starting" state would be keept. now {code} public void start() throws Exception { if (isStarting() || isStarted()) { // only start service if not already started LOG.trace("Service already started"); return; } if (starting.compareAndSet(false, true)) { LOG.trace("Starting service"); doStart(); started.set(true); starting.set(false); stopping.set(false); stopped.set(false); suspending.set(false); suspended.set(false); shutdown.set(false); shuttingdown.set(false); } } {code} before: {code} public void start(boolean startChildren) throws Exception { if (!started.get()) { if (starting.compareAndSet(false, true)) { boolean childrenStarted = false; Exception ex = null; try { if (childServices != null && startChildren) { ServiceHelper.startServices(childServices); } childrenStarted = true; doStart(); } catch (Exception e) { ex = e; } finally { if (ex != null) { try { stop(childrenStarted); } catch (Exception e) { // Ignore exceptions as we want to show the original exception } throw ex; } else { started.set(true); starting.set(false); stopping.set(false); stopped.set(false); suspending.set(false); suspended.set(false); shutdown.set(false); shuttingdown.set(false); } } } } {code} > Simplify ServiceSupport and introduce ServiceWithStatus interface to remove > tangle between util and support > ----------------------------------------------------------------------------------------------------------- > > Key: CAMEL-4381 > URL: https://issues.apache.org/jira/browse/CAMEL-4381 > Project: Camel > Issue Type: Improvement > Components: camel-core > Affects Versions: 2.8.0 > Reporter: Christian Schneider > Assignee: Christian Schneider > Fix For: 2.9.0 > > > Currently ServiceSupport and ServiceHelper form a dependency cycle. > ServiceSupport calls ServiceHelper to start and stop services and > ServiceSupport operate on ServiceSupport classes. > To solve that I introduce an Interface ServiceWithSupport (open for a better > naming). This interface extends Service and has all relevant methods from > ServiceSupport. So ServiceHelper can operate on ServiceWithStatus and the > tangle goes away. > Addtionally I split up ServiceSupport into ServiceSupport which has no > children and ChildServiceSupport which has. This is because we seem to have > only two classes that actually use the children functionality. The rest of > the classes that extend ServiceSupport have no children. So having them all > extend the old ServiceSupport introduces a lot of unneeded complexity. > The change should be fairly compatible. The only possible problem are third > party components that use children. As we only had two such components in > camel the chance that something breaks is fairly low. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira