Retain metadata during bean creation even with cacheBeanMetadata=false
Closes gh-23795 Closes gh-25749
This commit is contained in:
@@ -383,6 +383,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
finally {
|
||||
beanCreation.end();
|
||||
if (!isCacheBeanMetadata()) {
|
||||
clearMergedBeanDefinition(beanName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,7 +586,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
Class<?>[] typesToMatch = (FactoryBean.class == classToMatch ?
|
||||
new Class<?>[] {classToMatch} : new Class<?>[] {FactoryBean.class, classToMatch});
|
||||
|
||||
|
||||
// Attempt to predict the bean type
|
||||
Class<?> predictedType = null;
|
||||
|
||||
@@ -1409,7 +1411,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()) {
|
||||
if (containingBd == null && (isCacheBeanMetadata() || isBeanEligibleForMetadataCaching(beanName))) {
|
||||
this.mergedBeanDefinitions.put(beanName, mbd);
|
||||
}
|
||||
}
|
||||
@@ -1433,6 +1435,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
mbd.factoryMethodReturnType = previous.factoryMethodReturnType;
|
||||
mbd.factoryMethodToIntrospect = previous.factoryMethodToIntrospect;
|
||||
}
|
||||
if (previous.hasMethodOverrides()) {
|
||||
mbd.setMethodOverrides(new MethodOverrides(previous.getMethodOverrides()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user