Detect late-set primary markers for autowiring shortcut algorithm
Closes gh-34658
This commit is contained in:
@@ -1474,7 +1474,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
// Cache the merged bean definition for the time being
|
||||
// (it might still get re-merged later on in order to pick up metadata changes)
|
||||
if (containingBd == null && (isCacheBeanMetadata() || isBeanEligibleForMetadataCaching(beanName))) {
|
||||
this.mergedBeanDefinitions.put(beanName, mbd);
|
||||
cacheMergedBeanDefinition(mbd, beanName);
|
||||
}
|
||||
}
|
||||
if (previous != null) {
|
||||
@@ -1503,6 +1503,18 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache the given merged bean definition.
|
||||
* <p>Subclasses can override this to derive additional cached state
|
||||
* from the final post-processed bean definition.
|
||||
* @param mbd the merged bean definition to cache
|
||||
* @param beanName the name of the bean
|
||||
* @since 6.2.6
|
||||
*/
|
||||
protected void cacheMergedBeanDefinition(RootBeanDefinition mbd, String beanName) {
|
||||
this.mergedBeanDefinitions.put(beanName, mbd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the given merged bean definition,
|
||||
* potentially throwing validation exceptions.
|
||||
|
||||
@@ -1019,6 +1019,14 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
return super.obtainInstanceFromSupplier(supplier, beanName, mbd);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cacheMergedBeanDefinition(RootBeanDefinition mbd, String beanName) {
|
||||
super.cacheMergedBeanDefinition(mbd, beanName);
|
||||
if (mbd.isPrimary()) {
|
||||
this.primaryBeanNames.add(beanName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName, @Nullable Object[] args) {
|
||||
super.checkMergedBeanDefinition(mbd, beanName, args);
|
||||
|
||||
Reference in New Issue
Block a user