[
https://issues.apache.org/jira/browse/BEANUTILS-458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917119#comment-13917119
]
Manuel Dominguez Sarmiento commented on BEANUTILS-458:
------------------------------------------------------
This is the current code snippet:
private static <T> T checkConversionResult(Class<T> type, Object result) {
if (type == null) {
// in this case we cannot do much; the result object is returned
@SuppressWarnings("unchecked")
T temp = (T) result;
return temp;
}
if (type.isInstance(result)) {
return type.cast(result);
}
throw new ConversionException("Unsupported target type: " + type);
}
It should be changed to:
private static <T> T checkConversionResult(Class<T> type, Object result) {
if (type == null) {
// in this case we cannot do much; the result object is returned
@SuppressWarnings("unchecked")
T temp = (T) result;
return temp;
}
// HERE IS THE CHANGE
if (result == null) {
return null;
}
if (type.isInstance(result)) {
return type.cast(result);
}
throw new ConversionException("Unsupported target type: " + type);
}
> BaseLocaleConverter.checkConversionResult() fails with ConversionException
> when result is null when it should not
> -----------------------------------------------------------------------------------------------------------------
>
> Key: BEANUTILS-458
> URL: https://issues.apache.org/jira/browse/BEANUTILS-458
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: ConvertUtils & Converters
> Affects Versions: 1.9.0, 1.9.1
> Reporter: Manuel Dominguez Sarmiento
> Priority: Critical
>
> Null is a valid result for many, if not all converters. However, since
> BEANUTILS-445, this will always fail with ConversionException
> https://issues.apache.org/jira/browse/BEANUTILS-445
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)