I'm dealing with a strange OptionalDataException that I can't figure out.
I have objects coming in, which are saved to disk by a class that write them by decorating an OutputObjectStream
and calling its writeUnshared
method. Periodically, every 10000 objects, it calls flush
and reset
. Finally, it closes the stream.
This way, I create a small number of files that only contain serialized objects.
Here's the thing. After all those files are written, I take a pair and try to mergesort them. At this point, size of the files hasn't changed (as expected).
To do this, I start by opening two streams and calling readObject
on each one.
However, this call to readObject
(the first one on each stream) throws OptionalDataException
, everytime with eof = false, length = 4
, which as I understand indicates that I'm reading a primitive data type, or something else is happening that I'm not getting.