Skip to content

Commit de866a0

Browse files
committed
registerDependentBean resolves to the canonical bean name in order to handle alias references (SPR-7254)
1 parent d684e49 commit de866a0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2010 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -363,11 +363,12 @@ public void registerContainedBean(String containedBeanName, String containingBea
363363
* @param dependentBeanName the name of the dependent bean
364364
*/
365365
public void registerDependentBean(String beanName, String dependentBeanName) {
366+
String canonicalName = canonicalName(beanName);
366367
synchronized (this.dependentBeanMap) {
367-
Set<String> dependentBeans = this.dependentBeanMap.get(beanName);
368+
Set<String> dependentBeans = this.dependentBeanMap.get(canonicalName);
368369
if (dependentBeans == null) {
369370
dependentBeans = new LinkedHashSet<String>(8);
370-
this.dependentBeanMap.put(beanName, dependentBeans);
371+
this.dependentBeanMap.put(canonicalName, dependentBeans);
371372
}
372373
dependentBeans.add(dependentBeanName);
373374
}
@@ -377,7 +378,7 @@ public void registerDependentBean(String beanName, String dependentBeanName) {
377378
dependenciesForBean = new LinkedHashSet<String>(8);
378379
this.dependenciesForBeanMap.put(dependentBeanName, dependenciesForBean);
379380
}
380-
dependenciesForBean.add(beanName);
381+
dependenciesForBean.add(canonicalName);
381382
}
382383
}
383384

@@ -455,7 +456,7 @@ public void destroySingleton(String beanName) {
455456
removeSingleton(beanName);
456457

457458
// Destroy the corresponding DisposableBean instance.
458-
DisposableBean disposableBean = null;
459+
DisposableBean disposableBean;
459460
synchronized (this.disposableBeans) {
460461
disposableBean = (DisposableBean) this.disposableBeans.remove(beanName);
461462
}

org.springframework.core/src/main/java/org/springframework/core/SimpleAliasRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2010 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -145,8 +145,8 @@ else if (!registeredName.equals(resolvedName)) {
145145
*/
146146
public String canonicalName(String name) {
147147
String canonicalName = name;
148-
// Handle aliasing.
149-
String resolvedName = null;
148+
// Handle aliasing...
149+
String resolvedName;
150150
do {
151151
resolvedName = this.aliasMap.get(canonicalName);
152152
if (resolvedName != null) {

0 commit comments

Comments
 (0)