Description
I'm working on a project that initializes and shuts down the ActiveMQ CMS library multiple times. After upgrading from CMS 3.1.3 to 3.2.3, I noticed that my process crashes after these steps:
1) Initialize ActiveMQ CMS library
2) Create connection, session, etc and do work
3) Shut down ActiveMQ CMS library
4) Initialize ActiveMQ CMS library a second time
5) Create a connection, then a session... crash
First off, am I allowed to reinitialize the CMS library after shutting it down? Is it recommended not to?
Either way, the program crashes at:
/main/activemq/transport/tcp/TcpTransport.cpp line 163
I believe the error is in /main/decaf/net/SocketFactory.cpp. The static SocketFactory::defaultFactory pointer (line 30) is set while creating the first session. Then when shutting down the library, the Network object destroys the object pointed to by SocketFactory::defaultFactory. The next time around, SocketFactory::getDefault() will try to use the pointer, but the factory object has been destroyed, so the process crashes.
One possible fix is to modify the SocketFactory destructor to set the defaultFactory pointer to NULL. I have no idea if that's a good solution, though.
I will attach a test program to reproduce the crash.