Skip to content

NullPointerException in InjectionMetadata [SPR-7686] #12342

@spring-projects-issues

Description

@spring-projects-issues

Christophe Roudet opened SPR-7686 and commented

When using SpringBeanAutowiringSupport.processInjectionBasedOnServletContext()
a NullPointerException is raised in
InjectionMetadata.checkPropertySkipping(PropertyValues pvs)

protected boolean checkPropertySkipping(PropertyValues pvs) {
  if (this.skip == null) {
    synchronized (pvs) { // <-- NullPointerException
      if (this.skip == null) {

in AutowiredAnnotationBeanPostProcessor.processInjection(Object bean)
metadata inject is called with null for PropertyValues

public void processInjection(Object bean) throws BeansException {
  Class<?> clazz = bean.getClass();
  InjectionMetadata metadata = findAutowiringMetadata(clazz);
  try {
    metadata.inject(bean, null, null); // <-- pvs is null
  }
  catch (Throwable ex) {
    throw new BeanCreationException("Injection of autowired dependencies failed for class [" + clazz + "]", ex);
  }
}

Here is the stack trace:

java.lang.NullPointerException
 	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.checkPropertySkipping(InjectionMetadata.java:171)
 	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:526)
 	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
 	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.processInjection(AutowiredAnnotationBeanPostProcessor.java:300)
 	at org.springframework.web.context.support.SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(SpringBeanAutowiringSupport.java:110)

Affects: 3.0.5

Issue Links:

Referenced from: commits 9c64ac7

1 votes, 4 watchers

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