[ 
https://issues.apache.org/jira/browse/BEANUTILS-328?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Niall Pemberton updated BEANUTILS-328:
--------------------------------------

    Fix Version/s: LATER THAN 1.8.1

The reason it works this way is BeanUtils started life as part of the Struts 
web application framework, populating bean properties from request parameters - 
so changing this behaviour would need to be in a major version

> String[ ] to scalar undesired behavior at BeanUtilsBean causes limitations on 
> designing custom Converters
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: BEANUTILS-328
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-328
>             Project: Commons BeanUtils
>          Issue Type: Bug
>         Environment: Java 1.6, BeanUtils 1.8.
>            Reporter: Fábio Miranda
>            Priority: Minor
>             Fix For: LATER THAN 1.8.1
>
>
> Say you have an array entry that must be converted to a scalar property. A 
> very very simple example could be:
> String[] dateparams = new String[] { "10/10/2000", "10:00" };
> map.put("date", dateparams);
> BeanUtils.populate(object, map);
> So, you have a custom converter that should receive that array and perform 
> the appropriate conversions.
> Everything would be ok, except the fact BeanUtilsBean, when populating scalar 
> values, ignores all array values except first, as demonstrated by the 
> following BeanUtilsBean's code:
> // Value into scalar
>             if ((value instanceof String) || (value == null)) {
>                 newValue = getConvertUtils().convert((String) value, type);
>             } else if (value instanceof String[]) {
> // HERE
>                 newValue = getConvertUtils().convert(((String[]) value)[0],
>                                                 type);
>             } else {
>                 newValue = convert(value, type);
>             }
> It limitates ConvertUtils power on some complex conversion designs. In think 
> the code should be corrected to
>       newValue = getConvertUtils().convert(((String[]) value), type);
> and array logic should be delegated to the converters.
> Thanks in advance,
> Fábio.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to