Sending the same but modifed object over ObjectOutputStream

The stream has a reference graph, so an object which is sent twice will not give two objects on the other end, you will only get one. And sending the same object twice separately will give you the same instance twice (each with the same data - which is what you're seeing).

See the reset() method if you want to reset the graph.


Max is correct, but you can also use:

public void writeUnshared(Object obj);

See comment below for caveat