Skip to content

Commit 14fef19

Browse files
committed
Explicitly clear manually registered singleton names after destroySingletons call
As indicated by our recent Spring Integration test failure, autowiring attempts after context closing did not fail before. After the introduction of the separately managed manualSingletonNames set, the algorithm could run into a situation where a singleton name is still in the manualSingletonNames set but not in the singletonObjects map anymore. As a remedy, destroySingletons needs to explicitly clear the manualSingletonNames set in order to remove references to non-disposable singleton beans as well (which are otherwise left in the set since individual destroySingleton calls only come in for disposable beans with destroy methods). Issue: SPR-12404
1 parent 285dca0 commit 14fef19

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,13 @@ public void destroySingleton(String beanName) {
909909
clearByTypeCache();
910910
}
911911

912+
@Override
913+
public void destroySingletons() {
914+
super.destroySingletons();
915+
this.manualSingletonNames.clear();
916+
clearByTypeCache();
917+
}
918+
912919
/**
913920
* Remove any assumptions about by-type mappings.
914921
*/

0 commit comments

Comments
 (0)