Skip to content

NPE in ResolvableType.hasUnresolvableGenerics [SPR-11034] #15662

Closed
@spring-projects-issues

Description

@spring-projects-issues

Artem Bilan opened SPR-11034 and commented

Now Spring Data tests works, but we got another issue:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.integration.file.remote.session.SessionFactory org.springframework.integration.sftp.outbound.SftpServerOutboundTests.sessionFactory; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:505)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
... 45 more
Caused by: java.lang.NullPointerException
at org.springframework.core.ResolvableType.hasUnresolvableGenerics(ResolvableType.java:368)
at org.springframework.beans.factory.support.GenericTypeAwareAutowireCandidateResolver.checkGenericTypeMatch(GenericTypeAwareAutowireCandidateResolver.java:103)

In this case we ingect to the test class a mock of our generic interface.
The GenericTypeAwareAutowireCandidateResolver#checkGenericTypeMatch gets targetType for this bean from ResolvableType.forMethodReturnType(rbd.getResolvedFactoryMethod()) as a value:

targetType = {org.springframework.core.ResolvableType@2680}"?"
type = {com.sun.proxy.$Proxy11@2690}"T"
typeProvider = {org.springframework.core.SerializableTypeWrapper$MethodParameterTypeProvider@2691}
variableResolver = {org.springframework.core.ResolvableType$DefaultVariableResolver@2692}
isResolved = true
resolved = null
componentType = null

and further #checkGenericTypeMatch calls targetType.hasUnresolvableGenerics(), who ends up with NPE after resolve(), which, in turn, does fallback to null, because it is resolved and doesn't have a value for resolved property.
Unfortunately, I can't say which solution should right: do null check, or change something in the ResolvableType...

So, I reopen an issue, because the solution doesn't cover all cases


Affects: 4.0 RC1

Issue Links:

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions