Skip to content

Commit

Permalink
Defensively access existing beanDefinitionMap entries
Browse files Browse the repository at this point in the history
See gh-22263

(cherry picked from commit f1345aa)
  • Loading branch information
jhoeller committed Jul 20, 2020
1 parent eb4f91a commit e5227ee
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -543,8 +543,8 @@ public <T> Map<String, T> getBeansOfType(
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
List<String> result = new ArrayList<>();
for (String beanName : this.beanDefinitionNames) {
BeanDefinition beanDefinition = this.beanDefinitionMap.get(beanName);
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
BeanDefinition bd = this.beanDefinitionMap.get(beanName);
if (bd != null && !bd.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
result.add(beanName);
}
}
Expand Down Expand Up @@ -911,6 +911,7 @@ protected void resetBeanDefinition(String beanName) {
for (String bdName : this.beanDefinitionNames) {
if (!beanName.equals(bdName)) {
BeanDefinition bd = this.beanDefinitionMap.get(bdName);
// Ensure bd is non-null due to potential concurrent modification of beanDefinitionMap.
if (bd != null && beanName.equals(bd.getParentName())) {
resetBeanDefinition(bdName);
}
Expand Down

0 comments on commit e5227ee

Please sign in to comment.