J
JMC
Suppose a stream socket connection exists between P[roducer] and
C[onsumer], where P has an ObjectOutputStream on the socket and C has
an ObjectInputStream.
Then if P makes a sequence of OOS.writeXxxx calls, and these are not
matched exactly in sequence by OIS.readXxxx calls by C, then C will of
course get out of step and throw an exception, for example
OptionalDataException.
However, if P only makes OOS.writeObject calls, and C only makes
OIS.readObject calls, then they will stay in step as long as
OOS.writeObject does not throw a NotSerializableException.
But what if one of P's calls to OOS.writeObject does throw a
NotSerializableException, e.g. because some sub-sub-object deep in the
argument's graph is not serialisable? Then C's corresponding
OIS.readObject will get some sort of "malformed" object (or perhaps
null).
But then say P's next call to OOS.writeObject does not raise the
exception. Is it guaranteed that C will stay in step, and successfully
read the object? Or is it the case that sometimes P and C will need to
reset their connection to get back in step when P gets a
NotSerializableException?
C[onsumer], where P has an ObjectOutputStream on the socket and C has
an ObjectInputStream.
Then if P makes a sequence of OOS.writeXxxx calls, and these are not
matched exactly in sequence by OIS.readXxxx calls by C, then C will of
course get out of step and throw an exception, for example
OptionalDataException.
However, if P only makes OOS.writeObject calls, and C only makes
OIS.readObject calls, then they will stay in step as long as
OOS.writeObject does not throw a NotSerializableException.
But what if one of P's calls to OOS.writeObject does throw a
NotSerializableException, e.g. because some sub-sub-object deep in the
argument's graph is not serialisable? Then C's corresponding
OIS.readObject will get some sort of "malformed" object (or perhaps
null).
But then say P's next call to OOS.writeObject does not raise the
exception. Is it guaranteed that C will stay in step, and successfully
read the object? Or is it the case that sometimes P and C will need to
reset their connection to get back in step when P gets a
NotSerializableException?