commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <j...@apache.org>
Subject [jira] [Created] (BEANUTILS-445) Converters can return an invalid result object if a default value is set
Date Sat, 19 Oct 2013 19:17:41 GMT
Oliver Heger created BEANUTILS-445:
--------------------------------------

             Summary: Converters can return an invalid result object if a default value is
set
                 Key: BEANUTILS-445
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-445
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: ConvertUtils & Converters
    Affects Versions: 1.8.3
            Reporter: Oliver Heger
             Fix For: LATER THAN 1.8.4


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.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message