Resolution: Not A Bug
Affects Version/s: 1.4.7
Fix Version/s: None
I would like to suggest a small fix that would check that the result of a readResolve() call is not null.
While developing with XStream, I forgot to return the object in my readResolve() implementation, and the unmarshaling process continued without throwing any exception, resulting with a null object. It took me several hours to understand that the cause for a null object is my wrong readResolve() implementation. In this case I recommend to throw a descriptive exception that will help the developer to understand that something is wrong with their readResolve() implementation instead of returning a null object.
The suggested fix is to replace line 66 in SerializationMethodInvoker from:
Object invokeResult = readResolveMethod.invoke(result);
if (invokeResult == null)
throw new ObjectAccessException(resultType.getName() + ".readResolve() returned null");
Attached please find SVN patch file. I have run all unit tests and they completed successfully after applying this fix.