Details
-
Type: Bug
-
Status: Closed
-
Priority: Critical
-
Resolution: Fixed
-
Affects Version/s: 1.4.1
-
Fix Version/s: 1.4.2
-
Component/s: Converters
-
Labels:None
Description
I am using implicit collections and trying to serialize objects that sometimes have the collection set to java.util.Collections.EMPTY_LIST. I think that XStream should be able to handle this situation, but I get a ReferencedImplicitElementException.
In AbstractReflectionConverter's doMarshal() method, I would add a check to see if the object is an empty collection or array, and if it is, do not register the implicit with a ReferencingMarhasllingContext.)
I see how checking for an empty collection is not good enough since you could unmarshal an object, make a change to one collection, and expect it to see the change from the other reference. I still think that empty immutable collections (and zero-length arrays) could be marshalled without reference to other instances within the object graph. I change my recommendation to:
Check to see if the object is an empty array or is == Collections.EMPTY_LIST, Collections.EMPTY_MAP, or Collections.EMPTY_SET.