This problem can happen if you
- construct a new
ObjectInputStream
orObjectOutputStream
over the same socket instead of using the same ones for the life of the socket; - use another kind of stream over the same socket as well; or,
- use the object streams to read or write something that isn’t an object and you get out of sync.