ConversionService detects generic type declaration on target class behind proxy as well
Issue: SPR-14822
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.context.EmbeddedValueResolverAware;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.DecoratingProxy;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
@@ -97,9 +98,13 @@ public class FormattingConversionService extends GenericConversionService
|
||||
|
||||
static Class<?> getFieldType(Formatter<?> formatter) {
|
||||
Class<?> fieldType = GenericTypeResolver.resolveTypeArgument(formatter.getClass(), Formatter.class);
|
||||
if (fieldType == null && formatter instanceof DecoratingProxy) {
|
||||
fieldType = GenericTypeResolver.resolveTypeArgument(
|
||||
((DecoratingProxy) formatter).getDecoratedClass(), Formatter.class);
|
||||
}
|
||||
if (fieldType == null) {
|
||||
throw new IllegalArgumentException("Unable to extract parameterized field type argument from Formatter [" +
|
||||
formatter.getClass().getName() + "]; does the formatter parameterize the <T> generic type?");
|
||||
throw new IllegalArgumentException("Unable to extract the parameterized field type from Formatter [" +
|
||||
formatter.getClass().getName() + "]; does the class parameterize the <T> generic type?");
|
||||
}
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user