Details
Description
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.)
Acceptance tests with all implicit types at once and in a loop.