Re: [Simple-support] Avoiding NullPointerException
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2009-02-23 22:39:00
|
Hi, If you could send me a test case that would be great. Empty elements are null in Simple. There is an empty= attribute on @Attribute and @Text which let you specify a substitute to null. For example @Attribute(empty="[NULL]") private String name; This will mean an attribute of <element name="[NULL]"> Will deserialize the attribute name null. Also text like @Text(empty="This is null") private String value; <text>This is null</text> Will deserialize to null. However there is no such setting for a value in a map. I would greatly appreciate it if you could supply a test case to help me improve the overall stability of the project. Looks like an edge case around representing primitives as java.lang.Object again. Thanks, Niall --- On Mon, 2/23/09, Alan Deikman <Ala...@zn...> wrote: > From: Alan Deikman <Ala...@zn...> > Subject: [Simple-support] Avoiding NullPointerException > To: sim...@li... > Date: Monday, February 23, 2009, 1:20 PM > 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 > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, > San Francisco, CA > -OSBC tackles the biggest issue in open source: Open > Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open > source participation > -Receive a $600 discount off the registration fee with the > source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |