1. XStream
  2. XSTR-733

Intermittent loss of arrays on loading XML for classes with multiple implicit collections


    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.4
    • Fix Version/s: 1.4.5
    • Component/s: Core
    • Labels:
    • JDK version and platform:
      Sun Java 6 and 7 on Windows and OpenJDK 6b27 on Linux


      See the code attached. For a class with multiple implicit collections (an array and an ArrayList in this case), I get intermittent errors loading instances from XML, where the array field is null when it shouldn't be. Run BugTest.java with XStream libs and the input XML file on the classpath. Every few runs you get a NullPointerException trying to access the array (but it works perfectly on other runs).

      I tried different variants (such as adding a 'filler' field between them), and it still occurs. I'm 99% sure that it also occurred with two ArrayLists (instead of an array and an ArrayList), so it's not specific to the array/collection combination.

      It seems that making the array non-implicit fixes it (leaving the other implicit), but I need to more thoroughly test it. This seems to be independent of JRE version/vendor and OS. (Well, it occurred at least on Sun JRE 6/7 on Windows and OpenJDK 6 on Linux.)

      The error occurs maybe 3 in 20 times (but is variable), and it's something caused by the 'global' initialisation code: if I do the fromXML in a loop within the code (re-instantiating the XStream object each time) I either get them all failing or none. (So I assume XStream does some initialisation in other classes that isn't redone when new XStream instances are produced.)

      1. BugTest.java
        1.0 kB
        Stuart Rossiter
      2. ImplicitTest.java
        3 kB
        Jörg Schaible
      3. ImplicitTest2.java
        3 kB
        Stuart Rossiter
      4. in.xml
        0.2 kB
        Stuart Rossiter
      5. TestClass.java
        0.3 kB
        Stuart Rossiter


        • Assignee:
          Jörg Schaible
          Stuart Rossiter
        • Votes:
          0 Vote for this issue
          2 Start watching this issue


          • Created: