Skip to content

Commit

Permalink
Defensively access existing beanDefinitionMap entries
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller authored and xcl(徐程林) committed Aug 16, 2020
1 parent f2283b3 commit 1ed7db0
Showing 1 changed file with 3 additions and 4 deletions.
Expand Up @@ -652,8 +652,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 @@ -1059,8 +1059,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 1ed7db0

Please sign in to comment.