Affects Version/s: 1.3.1
Fix Version/s: 1.4
JDK version and platform:Sun 1.5.0_22-b03 for Windows
The deserialization of dynamic-proxies throws the following Exception when the serialized object contains circular references between dynamic-proxies: 'com.thoughtworks.xstream.converters.ConversionException: Invalid reference'.
We tracked the issue down to the class 'com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller' line 54 (release 1.3.1).
The problem is, that previous object's in the hierarchy representing dynamic-proxies were not put into the map 'AbstractReferenceUnmarshaller.values'.
So when the unmarshaller encounters a XML-tag defining a reference to another dynamic-proxy the reference could not be retrieved - and the result is the previous exception.
We provided an example as test-case '1' that reproduces the issue. None of the serialized proxy-tags with the corresponding IDs '1', '4', '7' and '10' can be found in the values-map of the AbstractReferenceUnmarshaller. The corresponding stack-trace tracks it down to this class/method.
The handlers of most of the dynamic-proxy (IDs '2', '5' and '8' from the XML-example) are present in the stack, but none of their proxy-parents.
The deserialization fails when the unsmarshaller is trying to receiver the object represented by the reference '7' as shown in the stack-trace.
A test-case with PoJos instead of dynamic-proxies was successful, so circular-references in general work fine.
Another dynamic-proxy test-case '2' with doublet-references instead of circular-references was successful too.
The reference '14' pointing to the dynamic-proxy with the ID '14' is resolved because that proxy-object could be found in the map 'AbstractReferenceUnmarshaller.values'.
The id-stack AbstractReferenceUnmarshaller.parentStack contains every previous object-ID for all three test-cases, so reading of IDs in general seems to work fine also.
We did not found a similar issue to that case. Most of the issues containing 'proxies' point to specific problems with CGLib-proxies or other frameworks.
We would be thankful for any advice or hint as circular references on dynamic-proxies are essential to our development.
The attachements are as follows:
1. - the serialized XML of the test-case '1' that fails
2. - the Exception stack-trace of the test-case '1' that fails.
3. - the serialized XML of test-case '2' that succeeds
- is related to
XSTR-580 Serialization of a write replaced object with field reference to itself does not work
Dynamic proxies can now be referenced also recursively. Fixed in trunk.
when I read first your issue talking about a test case, I thought you would have attached some kind of minimal unit test that demonstrates the problem. Can you provide one?