[Simple-support] Avoiding NullPointerException
Brought to you by:
niallg
|
From: Alan D. <Ala...@zn...> - 2009-02-23 21:20:25
|
Niall,
Thanks for the recent update to 2.0.3. It wasn't holding me up but it is great to get past that problem.
On to something else: I think this has been discussed before, but I couldn't find it in the archives. It has to do with serializing the empty String value: "". When reading it back in, you get a NullPointerException if the element is not marked required=false.
So how do we deal with that in a collection? My test case produces the following document:
<simpleBug1 id="0">
<test1 id="1">
<data id="2">
<entry>
<string id="3">key1</string>
<object class="java.lang.String" id="4">value</object>
</entry>
<entry>
<string id="5">key2</string>
<object class="java.lang.String" id="6"></object>
</entry>
</data>
</test1>
</simpleBug1>
Reading it back in gets:
Exception: java.lang.NullPointerException
java.lang.NullPointerException
at org.simpleframework.xml.core.Traverser.read(Traverser.java:79)
at org.simpleframework.xml.core.CompositeValue.read(CompositeValue.java:102)
at org.simpleframework.xml.core.CompositeMap.populate(CompositeMap.java:177)
etc. If you want me to send you the test case let me know, but again I don't know if this is a problem with simple or something I sould be doing but ain't. Thanks again.
--
Alan Deikman
|