Skip to content

Commit 2127b16

Browse files
author
Keith Donald
committed
catch ConversionFailedException and fallback to default container conversion logic rather than propogate exception
1 parent 9ece4a8 commit 2127b16

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

org.springframework.beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.commons.logging.LogFactory;
2929
import org.springframework.core.CollectionFactory;
3030
import org.springframework.core.MethodParameter;
31+
import org.springframework.core.convert.ConversionFailedException;
3132
import org.springframework.core.convert.ConversionService;
3233
import org.springframework.core.convert.TypeDescriptor;
3334
import org.springframework.core.type.filter.TypeFilter;
@@ -135,7 +136,11 @@ public <T> T convertIfNecessary(String propertyName, Object oldValue, Object new
135136
TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
136137
TypeDescriptor targetTypeDesc = typeDescriptor;
137138
if (conversionService.canConvert(sourceTypeDesc, targetTypeDesc)) {
138-
return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
139+
try {
140+
return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
141+
} catch (ConversionFailedException e) {
142+
// fallback to default conversion logic below
143+
}
139144
}
140145
}
141146

0 commit comments

Comments
 (0)