Skip to content

Commit a80305e

Browse files
committed
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
1 parent 1982c7e commit a80305e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,11 @@ private boolean isConvertibleProperty(String propertyName, BeanWrapper bw) {
17981798
*/
17991799
@SuppressWarnings("deprecation")
18001800
protected Object initializeBean(String beanName, Object bean, @Nullable RootBeanDefinition mbd) {
1801+
// Skip initialization of a NullBean
1802+
if (bean.getClass() == NullBean.class) {
1803+
return bean;
1804+
}
1805+
18011806
invokeAwareMethods(beanName, bean);
18021807

18031808
Object wrappedBean = bean;

0 commit comments

Comments
 (0)