Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 10952 invoked from network); 11 Sep 2003 12:32:58 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 11 Sep 2003 12:32:58 -0000 Received: (qmail 97121 invoked by uid 500); 11 Sep 2003 12:32:45 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 96994 invoked by uid 500); 11 Sep 2003 12:32:44 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 96920 invoked from network); 11 Sep 2003 12:32:43 -0000 Received: from unknown (HELO wien.mvd.org) (62.116.59.90) by daedalus.apache.org with SMTP; 11 Sep 2003 12:32:43 -0000 Received: from csturm ([192.168.0.71]) by wien.mvd.org (8.12.8/8.12.8) with ESMTP id h8BCRpF6004830 for ; Thu, 11 Sep 2003 14:27:52 +0200 Date: Thu, 11 Sep 2003 14:29:43 +0200 To: Jakarta Commons Users List Subject: Re: [betwixt] patch for bug when a method is called add() References: <8508178B-E3DD-11D7-9C9B-003065DC754C@blueyonder.co.uk> From: Christoph Sturm Organization: schaumwelt Content-Type: multipart/mixed; boundary=----------HU7CRDB1xluF3zjdnuoZSq MIME-Version: 1.0 Message-ID: In-Reply-To: <8508178B-E3DD-11D7-9C9B-003065DC754C@blueyonder.co.uk> User-Agent: Opera7.20/Win32 M2 build 3087 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ------------HU7CRDB1xluF3zjdnuoZSq Content-Type: text/plain; format=flowed; charset=iso-8859-15 Content-Transfer-Encoding: 8bit On Wed, 10 Sep 2003 23:24:18 +0100, robert burrell donkin wrote: > thanks for the patch. i'm going to wait until there's a unit test for > the bug before committing it. i was already suspecting that :) i am using betwixt on a tdd project, so i had this already covered in my testsuite. attached is another patch with both the fix and a test. -chris ------------HU7CRDB1xluF3zjdnuoZSq Content-Disposition: attachment; filename=betwixt.patch Content-Type: text/plain; name=betwixt.patch Content-Transfer-Encoding: 8bit Index: betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java,v retrieving revision 1.23 diff -u -r1.23 XMLIntrospectorHelper.java --- betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java 13 Jul 2003 21:28:10 -0000 1.23 +++ betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java 11 Sep 2003 12:29:13 -0000 @@ -462,6 +462,8 @@ if ( ( types.length == 1 ) || types.length == 2 ) { String propertyName = Introspector.decapitalize( name.substring(3) ); + if (propertyName.length() == 0) + continue; if ( log.isTraceEnabled() ) { log.trace( name + "->" + propertyName ); } Index: betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java,v retrieving revision 1.15 diff -u -r1.15 TestBeanWriter.java --- betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java 28 Jun 2003 10:34:28 -0000 1.15 +++ betwixt/src/test/org/apache/commons/betwixt/TestBeanWriter.java 11 Sep 2003 12:29:14 -0000 @@ -66,6 +66,7 @@ import java.io.StringWriter; import java.util.ArrayList; +import java.util.Collection; import junit.framework.Test; import junit.framework.TestSuite; @@ -74,7 +75,6 @@ import org.apache.commons.betwixt.io.BeanWriter; import org.apache.commons.betwixt.io.CyclicReferenceException; import org.apache.commons.logging.impl.SimpleLog; -import org.apache.commons.betwixt.digester.XMLIntrospectorHelper; import org.apache.commons.betwixt.strategy.CapitalizeNameMapper; import org.apache.commons.betwixt.strategy.HyphenatedNameMapper; @@ -670,5 +670,31 @@ parseString(xml), true); } + public void testBeanWriterWorksWithAnAddMethodAndACollection() throws Exception { + BeanWriter bw = new BeanWriter(); + try { + bw.write(new BeanWithAddMethod()); + } catch (IllegalArgumentException e) { + fail("BeanWriter fails when a method is just called add() and there is also a collection"); + } + } + static class BeanWithAddMethod { + public void add(Object x) + { + + } + + + public Collection getX() { + return x; + } + + public void setX(Collection x) { + this.x = x; + } + + Collection x; + } + } ------------HU7CRDB1xluF3zjdnuoZSq Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org ------------HU7CRDB1xluF3zjdnuoZSq--