Skip init/destroy method check for null beans

Issue: SPR-16063
This commit is contained in:
Juergen Hoeller
2017-10-12 15:31:57 +02:00
parent d611486978
commit 91a8993895
3 changed files with 4 additions and 4 deletions

View File

@@ -1764,7 +1764,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
}
if (mbd != null) {
if (mbd != null && bean.getClass() != NullBean.class) {
String initMethodName = mbd.getInitMethodName();
if (StringUtils.hasLength(initMethodName) &&
!(isInitializingBean && "afterPropertiesSet".equals(initMethodName)) &&

View File

@@ -1662,8 +1662,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
* @see AbstractBeanDefinition#getDestroyMethodName()
* @see org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
*/
protected boolean requiresDestruction(@Nullable Object bean, RootBeanDefinition mbd) {
return (bean != null &&
protected boolean requiresDestruction(Object bean, RootBeanDefinition mbd) {
return (bean.getClass() != NullBean.class &&
(DisposableBeanAdapter.hasDestroyMethod(bean, mbd) || (hasDestructionAwareBeanPostProcessors() &&
DisposableBeanAdapter.hasApplicableProcessors(bean, getBeanPostProcessors()))));
}