mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 22:19:03 +00:00
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:
+7
-1
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user