From: SourceForge.net <no...@so...> - 2006-09-14 05:11:46
|
Bugs item #1558357, was opened at 2006-09-14 13:11 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=474136&aid=1558357&group_id=54559 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: server Group: v0.7.6.1 Status: Open Resolution: None Priority: 5 Submitted By: Edwin Lee (edwin11) Assigned to: Nobody/Anonymous (nobody) Summary: ClassCastException in MultiplexConnectionServer Initial Comment: 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(); } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=474136&aid=1558357&group_id=54559 |