only try to convert to String if canConvert returns true

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2667 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller
2009-12-15 09:59:11 +00:00
parent 45ec0d2086
commit d39acb224e
@@ -116,9 +116,10 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
}
if (this.conversionService != null) {
// Try custom formatter...
TypeDescriptor td = getPropertyAccessor().getPropertyTypeDescriptor(fixedField);
if (td != null) {
return this.conversionService.convert(value, td, TypeDescriptor.valueOf(String.class));
TypeDescriptor fieldDesc = getPropertyAccessor().getPropertyTypeDescriptor(fixedField);
TypeDescriptor stringDesc = TypeDescriptor.valueOf(String.class);
if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, stringDesc)) {
return this.conversionService.convert(value, fieldDesc, stringDesc);
}
}
return value;