Skip to content

caught NullPointerException in AutowiredAnnotationBeanPostProcessor.determineRequiredStatus [SPR-9316] #13954

Closed
@spring-projects-issues

Description

@spring-projects-issues

Philippe Marschall opened SPR-9316 and commented

AutowiredAnnotationBeanPostProcessor.determineRequiredStatus uses ReflectionUtils.findMethod to look up a method named "required". If there is no such method then ReflectionUtils.findMethod returns null. However AutowiredAnnotationBeanPostProcessor.determineRequiredStatus never checks for null instead it directly passes the method to ReflectionUtils.invokeMethod which throws a NullPointerException which is then caught in a catch (Exception ex) block in AutowiredAnnotationBeanPostProcessor.determineRequiredStatus.

Annoations that don't have a method named "required" include @Inject @Value @Resource.

This is not so nice for several reasons:

  • when you debug one of your own NullPointerExceptions and set an exception breakpoint on NullPointerException you end up in Spring code
  • it uses NullPointerExceptions and catching them as part of normal control flow
  • filling in the stack trace of an exception is slow

Affects: 3.1.1

Issue Links:

Referenced from: commits 26ee0c4, 2624b90, 46bdb2d

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions