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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user