Only consider current context when finding lifecycle processor
Previously, LifecycleAutoConfiguration would check the current context and all of its ancestors for a lifecycle processor bean, only configuring a custom processor if one was not found. Every context has a lifecycle processor so this check meant that lifecycle processing timeout could not be customized in any context with a parent. This commit updates the auto-configuration to only check the current context. Closes gh-22014
This commit is contained in:
@@ -55,6 +55,18 @@ public class LifecycleAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void lifecycleProcessorIsConfiguredWithCustomDefaultTimeoutInAChildContext() {
|
||||
new ApplicationContextRunner().run((parent) -> {
|
||||
this.contextRunner.withParent(parent).withPropertyValues("spring.lifecycle.timeout-per-shutdown-phase=15s")
|
||||
.run((child) -> {
|
||||
assertThat(child).hasBean(AbstractApplicationContext.LIFECYCLE_PROCESSOR_BEAN_NAME);
|
||||
Object processor = child.getBean(AbstractApplicationContext.LIFECYCLE_PROCESSOR_BEAN_NAME);
|
||||
assertThat(processor).extracting("timeoutPerShutdownPhase").isEqualTo(15000L);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUserDefinesALifecycleProcessorBeanThenTheAutoConfigurationBacksOff() {
|
||||
this.contextRunner.withUserConfiguration(LifecycleProcessorConfiguration.class).run((context) -> {
|
||||
|
||||
Reference in New Issue
Block a user