Closed
Description
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:
- AutowiredAnnotationBeanPostProcessor.determineRequiredStatus(Annotation) throws NullPointerException if method wasnt found. [SPR-9364] #14001 AutowiredAnnotationBeanPostProcessor.determineRequiredStatus(Annotation) throws NullPointerException if method wasnt found. ("is duplicated by")