In 1.4, if the custom readObject or readExternal method of a serializable
or externalizable object closes the input stream it is passed as a parameter,
ObjectInputStream later throws an InternalError. Previous versions of
serialization allowed reads of such objects to succeed provided that no
attempts were made to read further data from the stream (after the close).
ObjectInputStream should be modified to tolerate (potentially multiple)
premature closes. The other possible fix would be for ObjectInputStream.close()
to throw an IOException if the close() is attempted inside a custom readObject
or readExternal method (since close() really shouldn't be called then); however,
this would appear to be inconsistent with the majority of InputStream subclasses
out there, which typically do not throw IOExceptions when closed.
Sample code is attached to this bug report which demonstrates the
difference in behavior--when run on 1.3.1 and earlier, the sample runs
to completion; with 1.4, an InternalError is thrown.