You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Fixed for 3.0.2: BeanPostProcessors are allowed to return a null bean value in the middle of the chain now.
As for your ordering question: BeanPostProcessors will only honor the Ordered interface when autodetected as beans (see AbstractApplicationContext's "registerBeanPostProcessors"). Objects registered through addBeanPostProcessor do not participate in that ordering; the addBeanPostProcessor call order is significant there.
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.:
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
Referenced from: commits 6118d67, 8975554
The text was updated successfully, but these errors were encountered: