XStream
  1. XStream
  2. XSTR-641

JettisonMappedXmlDriver does not correctly serialise empty java.util.ArrayList

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Component/s: Converters
    • Labels:
      None

      Description

      The attached unit test outputs:

      json={"com.thoughtworks.xstream.io.json.Foo":{"list":"","childs":[""]},"bar":["bar"]}
      before Foo: bar [] []
      after  Foo: null [] []
      
      junit.framework.AssertionFailedError: expected:<Foo: bar [] []> but was:<Foo: null [] []>
      	at com.thoughtworks.xstream.io.json.EmptyElementsTest.testEmptyArray(EmptyElementsTest.java:25)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:108)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
      

      As you can see the first array list is serialised as an empty string, the second is serialized as an array of empty strings, and bar is serialized as an array with a string in it.

      If you move the declaration of bar above the two lists in Foo.class, the test will pass, however the json produced is still suspicious.

      I suspect the issue is caused by the json writer being confused about its path, similar to what happened in http://jira.codehaus.org/browse/XSTR-640

        People

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

          Dates

          • Created:
            Updated:
            Resolved: