-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Jose Luis Martin opened SPR-10265 and commented
ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod() register scoped proxies using a RootBeanDefinition from ScopedProxyCreator.createScopedProxy() so the BeanDefinition cannot be overriden by other configuration classes.
// replace the original bean definition with the target one, if necessary
BeanDefinition beanDefToRegister = beanDef;
if (proxyMode != ScopedProxyMode.NO) {
BeanDefinitionHolder proxyDef = ScopedProxyCreator.createScopedProxy(
new BeanDefinitionHolder(beanDef, beanName), this.registry, proxyMode == ScopedProxyMode.TARGET_CLASS);
beanDefToRegister = proxyDef.getBeanDefinition();
}
I guess it should register a ConfigurationClassBeanDefinition instead. For example:
// replace the original bean definition with the target one, if necessary
BeanDefinition beanDefToRegister = beanDef;
if (proxyMode != ScopedProxyMode.NO) {
BeanDefinitionHolder proxyDef = ScopedProxyCreator.createScopedProxy(
new BeanDefinitionHolder(beanDef, beanName), this.registry, proxyMode == ScopedProxyMode.TARGET_CLASS);
beanDefToRegister = new ConfigurationClassBeanDefinition((RootBeanDefinition) proxyDef.getBeanDefinition(), configClass);
}
that uses the following constructor in ConfigurationClassBeanDefinition:
public ConfigurationClassBeanDefinition(RootBeanDefinition original, ConfigurationClass configClass) {
super(original);
this.annotationMetadata = configClass.getMetadata();
}
Affects: 3.2.1
Reference URL: http://stackoverflow.com/questions/14692561/how-do-i-override-a-scoped-bean-for-tests
Referenced from: commits 6b82d29
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug