XStream
  1. XStream
  2. XSTR-571

Cannot serialise syncronised RandomAccessList types in 1.3.1

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.4
    • Component/s: Core
    • Labels:
      None
    • JDK version and platform:
      Sun 1.6.0_05 Windows

      Description

      I can no longer serialise syncronised lists in 1.3.1.

      The following code:

      List<String> list = Collections.synchronizedList(new ArrayList<String>());
      list.add("test");
      XStream xstream = new XStream();
      String xml = xstream.toXML(list);
      System.out.println(xml);

      causes the following Exception:

      Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: Could not call java.util.Collections$SynchronizedList.writeObject() : Cannot reference implicit element
      ---- Debugging information ----
      implicit-element : [test]
      referencing-element : /java.util.Collections_-SynchronizedRandomAccessList/java.util.Collections_-SynchronizedCollection/default/mutex
      -------------------------------
      message : Could not call java.util.Collections$SynchronizedList.writeObject()
      cause-exception : com.thoughtworks.xstream.core.AbstractReferenceMarshaller$ReferencedImplicitElementException
      cause-message : Cannot reference implicit element
      -------------------------------
      at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteObject(SerializationMethodInvoker.java:103)
      at com.thoughtworks.xstream.converters.reflection.SerializableConverter.doMarshal(SerializableConverter.java:215)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:58)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:63)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:56)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:63)
      at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:98)
      at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:38)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:837)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:826)
      at com.thoughtworks.xstream.XStream.toXML(XStream.java:801)
      at com.thoughtworks.xstream.XStream.toXML(XStream.java:789)
      at test.Test.main(Test.java:56)
      Caused by: com.thoughtworks.xstream.core.AbstractReferenceMarshaller$ReferencedImplicitElementException: Cannot reference implicit element
      ---- Debugging information ----
      implicit-element : [test]
      referencing-element : /java.util.Collections_-SynchronizedRandomAccessList/java.util.Collections_-SynchronizedCollection/default/mutex
      -------------------------------
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:58)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:63)
      at com.thoughtworks.xstream.converters.reflection.SerializableConverter$1.defaultWriteObject(SerializableConverter.java:176)
      at com.thoughtworks.xstream.core.util.CustomObjectOutputStream.defaultWriteObject(CustomObjectOutputStream.java:80)
      at java.util.Collections$SynchronizedCollection.writeObject(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteObject(SerializationMethodInvoker.java:99)
      ... 16 more

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Ian Jones
        • Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: