BeanWrapper does not fall back to String constructor if ConversionService attempt failed before

Issue: SPR-9865
This commit is contained in:
Juergen Hoeller
2012-10-11 19:42:58 +02:00
parent d7825586dc
commit 9862fbfc01
2 changed files with 24 additions and 6 deletions

View File

@@ -198,7 +198,7 @@ class TypeConverterDelegate {
return (T) convertedValue.toString();
}
else if (convertedValue instanceof String && !requiredType.isInstance(convertedValue)) {
if (!requiredType.isInterface() && !requiredType.isEnum()) {
if (firstAttemptEx == null && !requiredType.isInterface() && !requiredType.isEnum()) {
try {
Constructor strCtor = requiredType.getConstructor(String.class);
return (T) BeanUtils.instantiateClass(strCtor, convertedValue);
@@ -220,7 +220,6 @@ class TypeConverterDelegate {
// It's an empty enum identifier: reset the enum value to null.
return null;
}
convertedValue = attemptToConvertStringToEnum(requiredType, trimmedValue, convertedValue);
standardConversion = true;
}