commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neeme Praks <ne...@apache.org>
Subject [betwixt] [patch] lazy initialization bug in ElementDescriptor
Date Wed, 14 May 2003 22:29:43 GMT

The *bug*: when a user specifies the ID attribute in beaninfo file, then 
the attribute declaration is ignored on the first bean and respected on 
all the following beans.
Example .betwixt file:
<info>
    <element name="Language">
        <attribute name="id" property="id"/>
        <addDefaults/>
    </element>
</info>

The *cause*? The method XMLBeanInfo.findIDAttribute() uses 
getElementDescriptor().hasAttributes() method to find out if the element 
has any attributes defined. This method makes the following check:
    return attributeDescriptors != null && attributeDescriptors.length > 0;
Everything would be ok, if the attributeDescriptors field wouldn't be 
lazily initialized (in getAttributeDescriptors() method). So, the fix is 
to change the check to use this method instead.
Also, similar issue with hasChildren() and hasContent() methods, but I'm 
not sure if they would result in similar bugs. I fixed them also, just 
in case.

Patch attached.

Rgds,
Neeme

Mime
View raw message