change in collection behavior (null references) between JIBX version 1.2.3 and JIBX version 1.2.2 -------------------------------------------------------------------------------------------------
Key: JIBX-449 URL: https://jira.codehaus.org/browse/JIBX-449 Project: JiBX Issue Type: Bug Components: BindGen, core Affects Versions: JiBX 1.2.3 Reporter: Klaus Claszen Attachments: jibx-collection-test.zip We noticed a really significant change in collection behavior between JIBX version 1.2.3 and JIBX version 1.2.2. As documented in the collection element documentation (http://jibx.sourceforge.net/binding/collection-element.html) unmarshalling an optional collection behaves like this: "If an element name is used with an optional collection, and that name is missing from an input XML document, the collection property will be set to null." Thus (we expect and noticed in the past) if no element name is used the collection property will not be set to null (but will be an empty collection). With version 1.2.3 the collection property will be set to null, even if NO element name in the binding.xml is used on the optional collection. To reproduce the changed behavior I provide a simple maven project using JIBX 1.2.3 with the following schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://foo.bar" elementFormDefault="qualified" targetNamespace="http://foo.bar"> <xs:element name="myCollection" type="tns:myCollection"/> <xs:complexType name="myCollection"> <xs:sequence> <xs:element type="xs:string" name="name" /> <xs:element type="xs:boolean" name="active" /> <xs:element type="xs:int" name="item" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:schema> The maven project will generate the XML mapping sources (MyCollection.java) and a binding.xml file. There is a simple test bar.foo.JibxUnmarshallingTest.testUnmarshalXmlWithMissingListItems() which will unmarshal an XML with no items for a list member and the result is that the object member list is null (test fails). If you change the jibx version in the pom.xml to 1.2.2 (and do some minor code changes in the test classes because getter and setter method names of generated code also changed from 1.2.2 (getItems()) to 1.2.3 (getItemList()) the list member of the unmarshalled object will be an empty list (test success)?. This issue breaks our code as we do not expect to get any null reference when requesting a list of an unmarshalled object. (There is a Wish Issue JIBX-418 on this topic - but I think it is a significant bug). -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ jibx-devs mailing list jibx-devs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-devs