Skip to content

Commit 6d6cd56

Browse files
committed
Improve logging of registerScope
Issue: SPR-12519
1 parent aafdcec commit 6d6cd56

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,13 @@ public void registerScope(String scopeName, Scope scope) {
855855
if (SCOPE_SINGLETON.equals(scopeName) || SCOPE_PROTOTYPE.equals(scopeName)) {
856856
throw new IllegalArgumentException("Cannot replace existing scopes 'singleton' and 'prototype'");
857857
}
858-
this.scopes.put(scopeName, scope);
858+
Scope previous = this.scopes.put(scopeName, scope);
859+
if (previous != null && logger.isInfoEnabled()) {
860+
logger.info("Replacing scope '" + scopeName + "' from '" + previous + "' to '" + scope);
861+
}
862+
else if (previous == null && logger.isDebugEnabled()) {
863+
logger.debug("Registering scope '" + scopeName + "' with '" + scope + "'");
864+
}
859865
}
860866

861867
@Override

0 commit comments

Comments
 (0)