Test case for event listener methods on bean with potentially inactive scope

Also taking the opportunity to refine the "No Scope registered" exception message a bit.

Issue: SPR-13681
This commit is contained in:
Juergen Hoeller
2015-11-25 16:56:39 +01:00
parent bb05bc7c01
commit 24e4f56d7e
2 changed files with 96 additions and 3 deletions

View File

@@ -334,7 +334,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
String scopeName = mbd.getScope();
final Scope scope = this.scopes.get(scopeName);
if (scope == null) {
throw new IllegalStateException("No Scope registered for scope '" + scopeName + "'");
throw new IllegalStateException("No Scope registered for scope name '" + scopeName + "'");
}
try {
Object scopedInstance = scope.get(beanName, new ObjectFactory<Object>() {
@@ -353,8 +353,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
catch (IllegalStateException ex) {
throw new BeanCreationException(beanName,
"Scope '" + scopeName + "' is not active for the current thread; " +
"consider defining a scoped proxy for this bean if you intend to refer to it from a singleton",
"Scope '" + scopeName + "' is not active for the current thread; consider " +
"defining a scoped proxy for this bean if you intend to refer to it from a singleton",
ex);
}
}