Skip to content

GenericConversionService.addConverter should be able to determine generic types from target class behind proxy [SPR-14822] #19388

Closed
@spring-projects-issues

Description

@spring-projects-issues

Harald Radi opened SPR-14822 and commented

WebMvcConfigurationSupport.mvcConversionService() creates a non-overrideable DefaultFormattingConversionService which scans for all Converter-beans. If one of those beans happens to be advised an IllegalArgumentException is thrown, since GenericConversionService.getRequiredTypeInfo() tries to derive the type info from the Proxy that only contains the type erasures and not the actual types.
Adding a proxy check and deriving the type info from the proxy-target would resolve that issue.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to the determine sourceType <S> and targetType <T> which your Converter<S, T> converts between; declare these generic types.

Affects: 4.3.3

Issue Links:

Referenced from: commits f9fcd24, f7d740f

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions