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 16525] - BeanUtils.setProperty is over-zealous at converting types
Date Wed, 20 Aug 2003 02:23: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=16525>.
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=16525

BeanUtils.setProperty is over-zealous at converting types





------- Additional Comments From scott_howlett@yahoo.com  2003-08-20 02:23 -------
I just ran into the same problem - my value is converted to a String 
unnecessarily by BeanUtils.setProperty(). Unfortunately, the calling code is 
not mine so I don't have an easy option of switching to copyProperty() instead.

It seems to me, though, that there is a simple solution. The toString() 
conversion performed in this line from setProperty:

  newValue = getConvertUtils().convert(value.toString(), type);

shouldn't be necessary. Although ConvertUtils.convert() wants a String value, 
it just passes it to a Converter that can take any Object as a value.

Why not change ConvertUtils.convert() to accept an Object value and avoid 
having BeanUtils convert it to a String first? That way, converters will still 
get first crack at a conversion.

Mime
View raw message