Petals CDK

Enhance Exception Handling for lifecycle operations in AbstractComponent

Details

  • Type: Improvement Request Improvement Request
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 5.1
  • Fix Version/s: 5.6.0
  • Component/s: None
  • Security Level: Public
  • Description:
    Hide

    In the AbstractComponent, lifecycle operations contain atomic calls to which all throws Exceptions. These exceptions are not handled atomically but globally with a single catch block. If one atomic operation fails, the next ones will never be called and the component can be in a inconcistent state or some resources will potentially never be released.
    For example look at the stop method :

    public final void stop() throws JBIException {
            this.logger.info("Stop component...");
            try {
                this.logger.fine("Calling specific stop...");
                this.doStop();
                this.logger.fine("Specific stop done.");
            } finally {
                this.notificationService.stop();
                this.deactivateServiceEndpointList();
                this.unregisterRuntimeConfigurationMBean();
                this.unregisterInterceptorManagerMBean();
                // stop first the acceptor Manager as it aggregates the worker
                // manager
                this.acceptorManager.stop();
                this.processorManager.stop();
                this.asyncManager.stop();
            }
            this.logger.info("Component stopped");
        }

    What happens if "this.notificationService.stop();" throws an exception?

    Show
    In the AbstractComponent, lifecycle operations contain atomic calls to which all throws Exceptions. These exceptions are not handled atomically but globally with a single catch block. If one atomic operation fails, the next ones will never be called and the component can be in a inconcistent state or some resources will potentially never be released. For example look at the stop method :
    public final void stop() throws JBIException {
            this.logger.info("Stop component...");
            try {
                this.logger.fine("Calling specific stop...");
                this.doStop();
                this.logger.fine("Specific stop done.");
            } finally {
                this.notificationService.stop();
                this.deactivateServiceEndpointList();
                this.unregisterRuntimeConfigurationMBean();
                this.unregisterInterceptorManagerMBean();
                // stop first the acceptor Manager as it aggregates the worker
                // manager
                this.acceptorManager.stop();
                this.processorManager.stop();
                this.asyncManager.stop();
            }
            this.logger.info("Component stopped");
        }
    What happens if "this.notificationService.stop();" throws an exception?
  • Environment:
    *

Activity

People

Dates

  • Created:
    Thu, 23 Sep 2010 - 23:19:33 +0200
    Updated:
    Mon, 12 Sep 2016 - 10:56:40 +0200
    Resolved:
    Mon, 12 Sep 2016 - 10:56:40 +0200