XStream
  1. XStream
  2. XSTR-672

ReferencedImplicitElementException when using Collections.EMPTY_LIST

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical 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.)

        Activity

        Hide
        Ken Geis added a comment -

        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.

        Show
        Ken Geis added a comment - 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.
        Hide
        Jörg Schaible added a comment -

        Exception made in trunk for Collections.EMPTY_LIST, Collections.EMPTY_SET and Collections.EMPTY_MAP.

        Show
        Jörg Schaible added a comment - Exception made in trunk for Collections.EMPTY_LIST, Collections.EMPTY_SET and Collections.EMPTY_MAP.

          People

          • Assignee:
            Jörg Schaible
            Reporter:
            Ken Geis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: