Ensure bean definitions can be removed concurrently
Prior to this commit, concurrent invocations of DefaultListableBeanFactory.removeBeanDefinition() could result in a NullPointerException. This commit fixes this by adding an appropriate not-null check in resetBeanDefinition(). Closes gh-23542
This commit is contained in:
@@ -1003,7 +1003,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
for (String bdName : this.beanDefinitionNames) {
|
||||
if (!beanName.equals(bdName)) {
|
||||
BeanDefinition bd = this.beanDefinitionMap.get(bdName);
|
||||
if (beanName.equals(bd.getParentName())) {
|
||||
// Ensure bd is non-null due to potential concurrent modification
|
||||
// of the beanDefinitionMap.
|
||||
if (bd != null && beanName.equals(bd.getParentName())) {
|
||||
resetBeanDefinition(bdName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user