Description
Daniel Walcher opened SPR-6926 and commented
We have a BeanPostProcessor that converts configuration beans into their actual value, sometimes the value is a 'null'. This causes a NPE as other internal spring BeanPostProcessor's do not correctly handle a null value.
Is this a bug or are we doing something wrong?
For example the org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor#postProcessBeforeInitialization does not validate the bean, attempting to call 'bean.getClass()' which causes a NPE.
Should it not prevent running other post processors if the bean has been nulled? i.e.:
public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
throws BeansException {
Object result = existingBean;
for (BeanPostProcessor beanProcessor : getBeanPostProcessors()) {
if (result == null) return;
result = beanProcessor.postProcessBeforeInitialization(result, beanName);
}
return result;
}
Also can someone confirm that the org.springframework.core.Ordered interface works for BeanPostProcessor. We have been unable to use this to create a work around, investigation has indicated that the logic seems to be missing to enforce ordering.
Affects: 3.0 GA, 3.0.1