[ https://issues.apache.org/jira/browse/BEANUTILS-199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Niall Pemberton resolved BEANUTILS-199. --------------------------------------- Resolution: Fixed Fixed by the changes implemented as part of BEANUTILS-258 > [beanutils] BeanUtils.setProperty is over-zealous at converting types > --------------------------------------------------------------------- > > Key: BEANUTILS-199 > URL: https://issues.apache.org/jira/browse/BEANUTILS-199 > Project: Commons BeanUtils > Issue Type: Improvement > Components: ConvertUtils & Converters > Affects Versions: 1.6 > Environment: Operating System: All > Platform: All > Reporter: Tim Vernum > Priority: Minor > Fix For: 1.8.0 > > Attachments: BeanUtils-invalid-conversion.patch, > copyProperty_extended.patch, Test.java, Test.java > > > As of Release 1.6, BeanUtils.setProperty goes to great lengths to convert > types > into Strings and then from Strings into valid target types, without ever > considering whether the original value was valid to start with. > e.g: > setProperty( bean, "object", new Integer(77) ) ; > will set the "object" in the bean to the String "77". > when what is intended is to set it to an Integer. > copyProperty gets it right, but it doesn't understand nested properties, so it > isn't useful for my situation. > PropertyUtils does a better job, but it doesn't do *any* conversions, so it > breaks in other situations. > There doesn't seem to be a reasonable way to say: > "set nested/indexed/mapped property 'X' in this bean to be value 'Y', and do > whatever conversions are necessary to get it there" > The options seem to be: > "set simple property X to value Y with proper conversions" > (BeanUtils.copyProperty) > "set complex property X to value Y with too many conversions" > (BeanUtils.setProperty) > "set complex property X to value Y with no conversions" > (PropertyUtils.setProperty) > Is BeanUtils.setProperty wrong? Or do we need another method that set complex > properties using the same conversion methds as "copyProperty" ? > I have a patch (which I'll attach) which makes setProperty do something closer > to what I think it should do, but I'm not sure if that's the correct approach. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]