I think I have discovered a bug, which occurs with a schema like this:

<xsd:element name="myElement">
        <xsd:choice>
                <xsd:element name="Choice-1" type="xsd:string" maxOccurs="unbounded"/>
                <xsd:element name="Choice-2" type="xsd:string"/>
        </xsd:choice>
</xsd:element>

Currently the XMLClassDescriptorImpl class performs this check to see if
a field contains a value:

        if(handler.getValue(object) != null) { /* code */ }

This simple null value test, however, always returns true when the field
is multi-valued, because even when the field is empty an array of length
zero is returned.

The test should be changed to be:

        Object value = handler.getValue(object);
        if ((value != null && !value.getClass().isArray()) ||
            (value != null && Array.getLength(value) != 0)) { /* code */ }

This checks if its null, and if it isn't, that it also isn't a zero
length array.

Thanks,
Brian

-- 
Brian DeVries  --  Sr. Software Engineer
mailto:[EMAIL PROTECTED]   http://www.intraware.com
Voice: 925.253.6516             Fax: 925.253.4542
-------------------------------------------------------
Intraware...Control Your Technology

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to