Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5
-
None
-
None
-
None
-
Operating System: All
Platform: All
-
15170
Description
When using BeanUtils.setProperty to set a property of type String, sometimes
it will be necessary to pass in an object of a primitive wrapper type (i.e.
java.lang.Integer). The current implementation throws an
IllegalArgumentException, ignoring the available toString() method on the
primitive wrapper. The current conversion code also will not delegate the
conversion to ConvertUtils.
Here's an example that illustrates the error:
BeanUtils.setProperty(new BeanComparator("foo"), "property", new Integer(1));
(See the attached testcase for the entire testcase.)
I have proposed a patch for this (see attached). However, I am not extremely
familiar with the BeanUtils code. The patch will, however, enable primitive
wrapper conversions to work correctly.