Hi,

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:

                    return readResolveMethod.invoke(result);
to:
                    Object invokeResult = readResolveMethod.invoke(result);
                    if (invokeResult == null)
                       throw new ObjectAccessException(resultType.getName()  + 
".readResolve() returned null");
                    return invokeResult;

Attached please find SVN patch file. I have run all unit tests and they 
completed successfully after applying this fix.

Regards,
Roy Zahor

Attachment: SerializationMethodInvoker.java.patch
Description: SerializationMethodInvoker.java.patch

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to