ObjectOutputStream & Socket
Posted on 2001-08-08
We have an application that writes objects through a Socket.
The Application includes these lines of code:
_objectOutputStream = new ObjectOutputStream(_socket.getOutputStream());
_objectInputStream = new ObjectInputStream(_socket.getInputStream());
Object inObject = _objectInputStream.readObject();
In general every thing works lovely and the objects (Command objects) "Ping-Pong" between the Client and the Server brings results for all the tasks.
But, there is a strange problem in one of the commands:
One of the Command objects contains an object of class C1,
which contains a collection of objects from class C2,
which also contains objects of some other classes.
All the classes are "implements Serializable".
This object (of class C1) is fetched successfully (wrapped by a Command object).
This object is also written back to the server successfully (wrapped by another Command object).
This object is a member of a JDialog that lets the modifications of the object content.
Closing this JDialog solve the problem (which will be described on the next line) for the moment.
Any subsequent writing of the object of class C1 (modified for several times) on the Client side,
wrapped by a Command object.
Reading constantly (at the Server side) a Command object wrapping the same object that was written by the Client at the first time.
During all the object writing attempts at the Client:
The wrapping Command object (at the Client side) contains the current modified object ! ... ???
Thanks in advance,