Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
-
Java 1.6, BeanUtils 1.8.
Description
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))
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.
Attachments
Issue Links
- is related to
-
BEANUTILS-409 BeanUtils - 'describe' method returning Incorrect array value
- Open