Skip to content

Autowiring throws NullPointerException [SPR-13599] #18177

@spring-projects-issues

Description

@spring-projects-issues

Michael Schoene opened SPR-13599 and commented

After switching to 4.2.2 I get the following exception during autowiring:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String de.ei.janet.server.Janet.saDir; nested exception is java.lang.NullPointerException
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	... 29 common frames omitted
Caused by: java.lang.NullPointerException: null
	at java.util.concurrent.ConcurrentHashMap.containsValue(ConcurrentHashMap.java:979) ~[na:1.8.0_60]
	at java.util.concurrent.ConcurrentHashMap$ValuesView.contains(ConcurrentHashMap.java:4664) ~[na:1.8.0_60]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.determineAutowireCandidate(DefaultListableBeanFactory.java:1228) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1124) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	... 31 common frames omitted

The reason seams to be the last changes in DefaultListableBeanFactory (Commit 097bcfb). This commit replaces HashMap with ConcurrentHashMap. After this change the fallback case in method determineAutowireCandidate throws the NullPointerException if beanInstance is null.


Affects: 4.2.2

Referenced from: commits 5386e8a

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions