Freeze configuration before invoking MBDPP instances
This commit updates refresh for AOT processing so that the configuration is frozen before invoking MergedBeanDefinitionPostProcessor instances. This makes sure that post-processed MergedBeanDefinitions are kept in cache and not lost if a component attempts to clear the metadata cache. Closes gh-28941
This commit is contained in:
parent
0a9db7cc47
commit
005713066c
|
|
@ -406,6 +406,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
|
|||
prepareBeanFactory(this.beanFactory);
|
||||
postProcessBeanFactory(this.beanFactory);
|
||||
invokeBeanFactoryPostProcessors(this.beanFactory);
|
||||
this.beanFactory.freezeConfiguration();
|
||||
PostProcessorRegistrationDelegate.invokeMergedBeanDefinitionPostProcessors(this.beanFactory);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -409,6 +409,19 @@ class GenericApplicationContextTests {
|
|||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void refreshForAotFreezeConfiguration() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.registerBeanDefinition("test", new RootBeanDefinition(String.class));
|
||||
MergedBeanDefinitionPostProcessor bpp = registerMockMergedBeanDefinitionPostProcessor(context);
|
||||
context.refreshForAotProcessing();
|
||||
RootBeanDefinition mergedBeanDefinition = getBeanDefinition(context, "test");
|
||||
verify(bpp).postProcessMergedBeanDefinition(mergedBeanDefinition, String.class, "test");
|
||||
context.getBeanFactory().clearMetadataCache();
|
||||
assertThat(context.getBeanFactory().getMergedBeanDefinition("test")).isSameAs(mergedBeanDefinition);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void refreshForAotInvokesBeanPostProcessorContractOnMergedBeanDefinitionPostProcessors() {
|
||||
MergedBeanDefinitionPostProcessor bpp = new MergedBeanDefinitionPostProcessor() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue