- priority: 5 --> 7
Calling
org.exolab.core.mipc.MultiplexConnectionServer.shutdownAll()
will cause a ClassCastException.
Here is why.
In MultiplexConnectionServer.run(), whenever a socket
connection is accepted, a new MultiplexConnection
object (subclass of Thread) is created and placed in
the ThreadGroup object, _connections. The thread is
then started.
So far so good.
However, in MultiplexConnection.run(), a MessageCopier
object is created. MessageCopier is also a subclass of
Thread, and as a ThreadGroup is not specified when
invoking the super constructor, it is placed in the
same ThreadGroup as its parent thread, the
MultiplexConnection object, and that is the ThreadGroup
_connections in MultiplexConnectionServer.
Hence, the ThreadGroup _connections in
MultiplexConnectionServer contains both
MultiplexConnection objects and MessageCopier objects.
MultiplexConnection is a subclass of
MultiplexConnectionIfc, but MessageCopier is not.
Therefore, in the shutdownAll() method of
MultiplexConnectionServer, the line
((MultiplexConnectionIfc) connections[i]).finish();
causes a ClassCastException (trying to cast an instance
of MessageCopier to the type MultiplexConnectionIfc).
i would propose replacing the above line with:
if (connections[i] instanceof MultiplexConnectionIfc)
{
((MultiplexConnectionIfc) connections[i]).finish();
}
else if (connections[i] instanceof MessageCopier)
{
((MessageCopier) connections[i]).finish();
}