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

NPE in ArrayConverter when converting a non-quoted string with underscores to a string array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.0-BETA
    • 1.8.0
    • None
    • All

    Description

      An array value passed as:

      this_is_my_first_value,this_is_my_second_value

      causes an NPE after the first token is returned:

      java.lang.NullPointerException
      at org.apache.commons.beanutils.converters.ArrayConverter.parseElements(ArrayConverter.java:440)
      at org.apache.commons.beanutils.converters.ArrayConverter.convertToCollection(ArrayConverter.java:343)
      at org.apache.commons.beanutils.converters.ArrayConverter.convertToType(ArrayConverter.java:279)
      at org.apache.commons.beanutils.converters.AbstractConverter.convert(AbstractConverter.java:171)
      at org.apache.commons.beanutils.converters.ConverterFacade.convert(ConverterFacade.java:60)
      at org.apache.commons.beanutils.BeanUtilsBean.convert(BeanUtilsBean.java:1079)
      at org.apache.commons.beanutils.BeanUtilsBean.copyProperty(BeanUtilsBean.java:437)
      at org.apache.commons.beanutils.BeanUtilsBean.copyProperties(BeanUtilsBean.java:270)
      at org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:137)

      The parse list being built contains "this". The sval field of the StreamTokenizer is indeed null - presumably because it has found the the underscore.

      Workaround is to quote the string. See BEANUTILS-301 for an improvement request to allow _ as part of the default word character set.

      Attachments

        Activity

          People

            niallp Niall Pemberton
            martin.bartlett Martin Bartlett
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: