datanucleus-core icon indicating copy to clipboard operation
datanucleus-core copied to clipboard

Enhancement contract : cater for serialisation of detachedState when user has overridden writeObject/writeReplace without calling "defaultWriteObject"

Open andyjefferson opened this issue 8 years ago • 0 comments

The enhancement contract will cater for normal Java serialisation where a user doesn't change the default process, OR where they make use of out.defaultWriteObject(). The dnDetachedState field is serialised/deserialised since not transient.

If the user deviates from this then it will not be serialised, and hence detached state is lost. We would want to detect the overriding of writeObject/writeReplace and the absence of a call to defaultWriteObject (defaultReadObject) and in that case add on

out.writeObject(dnDetachedState);

as well as

dnDetachedState = (Object[])in.readObject();

andyjefferson avatar Apr 11 '16 07:04 andyjefferson