Skip to content

Commit

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

(cherry picked from commit f1345aa)
  • Loading branch information
jhoeller authored and zx20110729 committed Feb 18, 2022
1 parent a69ce28 commit 78088a4
Showing 1 changed file with 3 additions and 4 deletions.
Expand Up @@ -641,8 +641,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 @@ -1023,8 +1023,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 the beanDefinitionMap.
// 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 78088a4

Please sign in to comment.