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

Converters can return an invalid result object if a default value is set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.3
    • 1.9.0
    • None

    Description

      For BeanUtils converters derived from AbstractConverter it is possible to set a default value. If the default flag is set, this value is returned for null input, but also if a conversion to an unsupported type is attempted (in this case, a conversion of the default value to the target class is tried, but if this fails, the default value is returned directly). This causes the converter to return an object of another class than requested.

      IMHO this is a source of ClassCastExceptions and should be changed. A converter should never return an object of a different type than the requested target class. So either perform a successful conversion (if necessary, convert the default value to the target class) or throw an exception.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              oheger Oliver Heger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: