Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10265

ConfigurationClassBeanDefinitionReader: Scoped-Proxy BeanDefinitions cannot be overriden by other configuration classes

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.2.1
    • Fix Version/s: 3.2.2
    • Component/s: Core
    • Labels:
      None

      Description

      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();
      		}
      

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              jlm Jose Luis Martin
              Last updater:
              Juergen Hoeller
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                5 years, 11 weeks, 6 days ago