Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-84

BeanUtils.populate() throws IllegalArgumentException when setting indexed property as array.

    XMLWordPrintableJSON

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[] =

      { "String 0", "String 1", "String 2", "String 3", "String 4" }

      ;

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

      */

      Attachments

        Activity

          People

            Unassigned Unassigned
            jerome.jacobsen@gentootech.com Jerome Jacobsen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: