avoid ConverterNotFoundException if source object is assignable to target type

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3426 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller
2010-06-15 09:35:39 +00:00
parent c04935fc26
commit 463cd8e0b0
2 changed files with 28 additions and 2 deletions
@@ -172,7 +172,13 @@ public class GenericConversionService implements ConversionService, ConverterReg
}
GenericConverter converter = getConverter(sourceType, targetType);
if (converter == null) {
throw new ConverterNotFoundException(sourceType, targetType);
if (targetType.getType().isInstance(source)) {
logger.debug("No converter found - returning assignable source object as-is");
return source;
}
else {
throw new ConverterNotFoundException(sourceType, targetType);
}
}
Object result = ConversionUtils.invokeConverter(converter, source, sourceType, targetType);
if (logger.isDebugEnabled()) {