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

Exception when setting indexed properties: "Default conversion to ArrayList failed"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.9.2, 1.9.3
    • 1.9.3
    • commons-beanutils-1.9.3-20160606.150953-11
      jdk1.8.0_92

    Description

      An exception is thrown when adding indexed properties to a DynaBean. This worked perfectly with Version 1.8.3

      org.apache.commons.beanutils.ConversionException: Default conversion to ArrayList failed.
      at org.apache.commons.beanutils.converters.AbstractConverter.handleMissing(AbstractConverter.java:314)
      at org.apache.commons.beanutils.converters.AbstractConverter.handleError(AbstractConverter.java:269)
      at org.apache.commons.beanutils.converters.AbstractConverter.convert(AbstractConverter.java:177)
      at org.apache.commons.beanutils.converters.ConverterFacade.convert(ConverterFacade.java:61)
      at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:491)
      at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1004)
      at BeanUtilsBeanTestApp.main(BeanUtilsBeanTestApp.java:11)
      Caused by: org.apache.commons.beanutils.ConversionException: Can't convert value '' to type class java.util.ArrayList
      at org.apache.commons.beanutils.converters.AbstractConverter.conversionException(AbstractConverter.java:474)
      at org.apache.commons.beanutils.converters.StringConverter.convertToType(StringConverter.java:96)
      at org.apache.commons.beanutils.converters.AbstractConverter.handleMissing(AbstractConverter.java:312)
      ... 6 more

      Test Class:
      import org.apache.commons.beanutils.BeanUtilsBean;
      import org.apache.commons.beanutils.LazyDynaBean;

      public class BeanUtilsBeanTestApp {

      public static void main(String[] args) {
      try

      { LazyDynaBean lazyDynaBean = new LazyDynaBean(); BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance(); beanUtilsBean.setProperty(lazyDynaBean, "x[0]", "x1"); beanUtilsBean.setProperty(lazyDynaBean, "x[1]", "x2"); System.out.println(lazyDynaBean.get("x")); // output using commons-beanutils 1.8.3: [x1, x2] }

      catch (Exception e)

      { e.printStackTrace(); }

      }
      }

      Attachments

        1. BeanUtilsBean.java.patch
          0.6 kB
          Bernhard Seebass
        2. BeanUtilsBeanTest.java
          0.6 kB
          Bernhard Seebass

        Activity

          People

            Unassigned Unassigned
            seebass Bernhard Seebass
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: