Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0
-
None
-
None
-
None
-
Operating System: other
Platform: Other
-
9868
Description
BeanUtils.populate throws an IllegalArgumentException when setting an indexed
String property as an array.
For example:
public class TestBean {
private String stringIndexed[] =
;
public String[] getStringIndexed()
{ return (this.stringIndexed); }public void setStringIndexed(String value[])
{ this.stringIndexed = value; }public String getStringIndexed(int index)
{ return (stringIndexed[index]); }public void setStringIndexed(int index, String value)
{ stringIndexed[index] = value; }}
. . .
public class BeanUtilsTestCase extends TestCase {
. . .
public void testPopulateIndexedProperty2 {
// verify populate as String array.
Map aMap = new HashMap();
String[] compArray = new String[]
{"STRIDX 0", "STRIDX 1", "STRIDX 2", "STRIDX 3"};
aMap.put("stringIndexed", comp);
BeanUtils.populate(bean, aMap); // throws IllegalArgumentException!!!
}
}
I believe this should work because TestBean has the array setter method.
public void setStringIndexed(String value[])
Note, if I remove just the indexed setter it works!
/* public void setStringIndexed(int index, String value) { stringIndexed[index] = value; }
*/