You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/07/12 20:27:49 UTC
DO NOT REPLY [Bug 10753] -
BeanUtils.populate() does bad conversion on DynaBean
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 -------
<shame> accidentally posted </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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>