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 15170] - BeanUtils.setProperty doesn't convert primitive wrappers
Date Wed, 11 Dec 2002 06:17:29 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=15170>.
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=15170

BeanUtils.setProperty doesn't convert primitive wrappers

rg@onepercentsoftware.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |



------- Additional Comments From rg@onepercentsoftware.com  2002-12-11 06:17 -------
Rodney,

Thanks for committing the converter code and adding the testcase.

Unfortunately, these fixes do not address the bug I reported here.  This bug 
only occurs when attempting to set a String property using a number wrapped in 
a primitive wrapper class.  In order to illustrate this behavior, add the 
following lines to the new testcase testSetPropertyOnPrimitavieWrappers() 
[sic]:

BeanUtils.setProperty(bean,"stringProperty", new Integer(1));
assertEquals(1,Integer.parseInt(bean.getStringProperty()));

(i.e. set a String property instead of an int property.)  In this case, the 
ConvertUtils code is never called.  The if block beginning around line 901 
(comment: "Value into scalar") maps this case to the final else case, which 
will attempt to set the property using the wrapper class (which will fail).  I 
believe you need to add another check for primitive wrapper classes (or 
perhaps something more generic like testing the existence of a suitable 
converter), as I did in my suggested patch.

--
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