commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 10753] - BeanUtils.populate() does bad conversion on DynaBean
Date Fri, 12 Jul 2002 18:27:49 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10753>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10753

BeanUtils.populate() does bad conversion on DynaBean





------- Additional Comments From lalyos@yahoo.com  2002-07-12 18:27 -------
&lt;shame> accidentally posted &lt;/shame>

With debug level I have got the following:

0   ... - BeanUtils.populate(BasicDynaBean@4a5ab2, {customer(name)=joe})
10  ... -   setProperty(BasicDynaBean@4a5ab2, customer(name), joe)
111 ... - Convert string 'joe' to class 'java.util.HashMap'
131 ... -   Using converter 
org.apache.commons.beanutils.converters.StringConverter@7e64b9

This works only until you don't register a MapConverter. So I think the 
BeanUtils.popultae don't need any conversion if the target property is a map. 
The following patch could solve this problem:

Index: BeanUtils.java
===================================================================
RCS file: /home/cvspublic/jakarta-
commons/beanutils/src/java/org/apache/commons/beanutils/BeanUtils.java,v
retrieving revision 1.24
diff -u -r1.24 BeanUtils.java
--- BeanUtils.java      7 Jul 2002 23:08:41 -0000       1.24
+++ BeanUtils.java      12 Jul 2002 18:26:42 -0000
@@ -655,7 +655,12 @@
                 type = descriptor.getPropertyType();
             }
         }
-
+
+        // If the property is mapped, no conversion needed
+        if (key != null) {
+            type = Object.class;
+        }
+
         // Convert the specified value to the required type
         Object newValue = null;
         if (type.isArray() && (index < 0)) { // Scalar value into array

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message