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

Christophe Hamerling made changes - Thu, 23 Sep 2010 - 23:46:25 +0200
Field Original Value New Value
Description 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?
 
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 :

{code:java}
    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");
    }
{code}
    
 What happens if "this.notificationService.stop();" throws an exception?
 
Priority Blocker [ 1 ]
Hide
Victor NOËL added a comment - Mon, 5 Oct 2015 - 11:26:57 +0200

Moreover, we should never have methods that throw exceptions in a finally block.

Show
Victor NOËL added a comment - Mon, 5 Oct 2015 - 11:26:57 +0200 Moreover, we should never have methods that throw exceptions in a finally block.
Victor NOËL made changes - Mon, 5 Oct 2015 - 11:26:57 +0200
Status New [ 10000 ] Open [ 10002 ]
Priority Blocker [ 1 ] Major [ 3 ]
Assignee Mathieu Carrolle [ mcarrolle ] Victor NOËL [ vnoel ]
Victor NOËL made changes - Mon, 12 Sep 2016 - 10:56:04 +0200
Status Open [ 10002 ] In Progress [ 10003 ]
Hide
Victor NOËL added a comment - Mon, 12 Sep 2016 - 10:56:40 +0200

This was fixed with PETALSDISTRIB-240 in 5.6.0.

Show
Victor NOËL added a comment - Mon, 12 Sep 2016 - 10:56:40 +0200 This was fixed with PETALSDISTRIB-240 in 5.6.0.
Victor NOËL made changes - Mon, 12 Sep 2016 - 10:56:40 +0200
Status In Progress [ 10003 ] Resolved [ 10004 ]
Fix Version/s 5.6.0 [ 10611 ]
Resolution Fixed [ 1 ]
Transition Status Change Time Execution Times Last Executer Last Execution Date
New New Open Open
1837d 12h 7m
1
Victor NOËL
Mon, 5 Oct 2015 - 11:26:57 +0200
Open Open In Progress In Progress
342d 23h 29m
1
Victor NOËL
Mon, 12 Sep 2016 - 10:56:04 +0200
In Progress In Progress Resolved Resolved
36s
1
Victor NOËL
Mon, 12 Sep 2016 - 10:56:40 +0200



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