Browse Source

catch ConversionFailedException and fallback to default container conversion logic rather than propogate exception

pull/7/head
Keith Donald 14 years ago
parent
commit
2127b16051
  1. 7
      org.springframework.beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java

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

@ -28,6 +28,7 @@ import org.apache.commons.logging.Log; @@ -28,6 +28,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.CollectionFactory;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.type.filter.TypeFilter;
@ -135,7 +136,11 @@ class TypeConverterDelegate { @@ -135,7 +136,11 @@ class TypeConverterDelegate {
TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
TypeDescriptor targetTypeDesc = typeDescriptor;
if (conversionService.canConvert(sourceTypeDesc, targetTypeDesc)) {
return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
try {
return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
} catch (ConversionFailedException e) {
// fallback to default conversion logic below
}
}
}

Loading…
Cancel
Save