On Wed, 10 Sep 2003 23:24:18 +0100, robert burrell donkin <[EMAIL PROTECTED]> 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
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(<type>) 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;
+    }
+
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to