mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-05 22:49:02 +00:00
Skip initialization of a NullBean
Prior to this commit, AbstractAutowireCapableBeanFactory's initializeBean() method always attempted to initialize a NullBean. However, invokeInitMethods() (which is invoked by initializeBean()) skips processing of a NullBean, which is logical since a NullBean will never contain init-methods. In practice, initialization and post-processing of a NullBean should not result in any change to the NullBean. This commit therefore skips initialization of a NullBean altogether. Closes gh-35165
This commit is contained in:
+5
@@ -1798,6 +1798,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Object initializeBean(String beanName, Object bean, @Nullable RootBeanDefinition mbd) {
|
||||
// Skip initialization of a NullBean
|
||||
if (bean.getClass() == NullBean.class) {
|
||||
return bean;
|
||||
}
|
||||
|
||||
invokeAwareMethods(beanName, bean);
|
||||
|
||||
Object wrappedBean = bean;
|
||||
|
||||
Reference in New Issue
Block a user