Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 7729 invoked from network); 16 May 2003 13:35:11 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 16 May 2003 13:35:11 -0000 Received: (qmail 4263 invoked by uid 97); 16 May 2003 13:37:18 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 4256 invoked from network); 16 May 2003 13:37:17 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 16 May 2003 13:37:17 -0000 Received: (qmail 6560 invoked by uid 500); 16 May 2003 13:34:56 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 6524 invoked from network); 16 May 2003 13:34:55 -0000 Received: from pcow053o.blueyonder.co.uk (HELO blueyonder.co.uk) (195.188.53.96) by daedalus.apache.org with SMTP; 16 May 2003 13:34:55 -0000 Received: from localhost ([80.194.24.21]) by blueyonder.co.uk with Microsoft SMTPSVC(5.5.1877.757.75); Fri, 16 May 2003 14:36:07 +0100 Date: Fri, 16 May 2003 14:34:01 +0100 Subject: Re: [betwixt] [patch] lazy initialization bug in ElementDescriptor Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v482) From: robert burrell donkin To: "Jakarta Commons Developers List" Content-Transfer-Encoding: 7bit In-Reply-To: <3EC2C357.3010708@apache.org> Message-Id: <0DEFDEEA-87A3-11D7-BE63-003065DC754C@blueyonder.co.uk> X-Mailer: Apple Mail (2.482) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N committed. many thanks. - robert On Wednesday, May 14, 2003, at 11:29 PM, Neeme Praks wrote: > > 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: > > > > > > > > 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 > Index: src/java/org/apache/commons/betwixt/ElementDescriptor.java > =================================================================== > RCS file: /home/cvspublic/jakarta- > commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java, > v > retrieving revision 1.8 > diff -u -r1.8 ElementDescriptor.java > --- src/java/org/apache/commons/betwixt/ElementDescriptor.java 19 Mar 2003 > 22:59:01 -0000 1.8 > +++ src/java/org/apache/commons/betwixt/ElementDescriptor.java 14 May 2003 > 22:15:05 -0000 > @@ -168,7 +168,7 @@ > * @see #getElementDescriptors > */ > public boolean hasChildren() { > - return elementDescriptors != null && elementDescriptors.length > > 0; > + return getElementDescriptors().length > 0; > } > > /** > @@ -177,7 +177,7 @@ > * @see #getAttributeDescriptors > */ > public boolean hasAttributes() { > - return attributeDescriptors != null && > attributeDescriptors.length > 0; > + return getAttributeDescriptors().length > 0; > } > > /** > @@ -186,7 +186,7 @@ > * @see #getContentDescriptors > */ > public boolean hasContent() { > - return contentDescriptors != null && contentDescriptors.length > > 0; > + return getContentDescriptors().length > 0; > } > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org