Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
SocketCreatorFactory is primarily accessed through a singleton. The "module" is initialized via the static setDistributionConfig() method and de-initialized via the static close() method. Unfortunately though, a call to setDistributionConfig() is insufficient to fully initialize the singleton since doing so does not initialize (clear) the Map<SecurableCommunicationChannel, SocketCreator> socketCreators field.
This bites in tests. If a test interacts with the singleton and fails to call SocketCreatorFactory.close() at the end, then subsequent tests, which are merely calling setDistributionConfig() are starting with a socketCreators map that is in some indeterminate state. The obvious solution, of clearing the map in setDistributionConfig() is problematic because there are other static methods on the class that may be relying on the state of that map.
So rather than spending effort trying to shore up the static interface to the singleton, this ticket proposes eliminating the singleton (global variable) entirely. Clients that need a SocketCreatorFactory should use one. They should interact with it solely through instance methods.