Details
-
Type:
Patch submission
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.4.4, 2.1.1
-
Fix Version/s: 2.1.2
-
Component/s: Core: Lifecycle, Core: Transports
-
Labels:None
-
Environment:
1.4.x trunk, Windows XP
-
Includes test case?:yes
-
User impact:Medium
-
Similar Issues:None
Description
org.mule.providers.AbstractConnector implements the basic lifecycle of a connector by defining several abstract methods (e.g., doInitialise, doConnect, doStart, doStop, doDisconnect, doDispose). These abstract methods should only called when the connector's state changes (i.e., calling AbstractConnector.startConnector twice results in the second call being a NOP).
Two issues:
1) AbstractConnector.initialise() throws an AlreadyInitialisedException if it is called when the connector has already been initialised. This behaviour is inconsistent with the way AbstractConnector.startConnector() and AbstractConnector.stopConnector() handle multiple calls (i.e., NOPs instead of exceptions). However, this patch does not address this difference as it's arguable which is the better behaviour.
2) AbstractConnector.dispose() does not throw an AlreadyDisposedException, nor does it perform a NOP if the connector is already disposed. Instead, it calls doDispose() regardless. It's a reasonable expection of a connector writer that doDispose() should only be called once. Because it is difficult to handle exceptions during disposal, it is understandable that no AlreadyDisposedException should be thrown; however, multiple disposal calls should be NOPs.
The attached patch changes AbstractConnector.dispose() so that it logs a message if the connector is already disposed instead of calling doDispose()
Junit test and patch attached.
1) Unzip MulePatch.zip
2) Edit build.xml to set mule.home to your Mule installation
3) Run "ant test-broken" to run the Junit test with the unpatched code. Observe that one of the tests fails and consult test-report for details.
4) Run "ant test-fixed" to run Junit test with patched code and observer that all tests pass.