Conversation
Register shutdown participants as beans are stopped so callbacks from dependent beans in another phase cannot end the wait prematurely. Preserve phase timeouts and cover both callback completion orders. Closes spring-projectsgh-28277 Signed-off-by: kimsanha <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes gh-28277.
DefaultLifecycleProcessorsizes each shutdown latch from the beans in one phase, but dependent beans in other phases decrement the same latch. A fast dependent can therefore letclose()return while another shutdown callback is still pending.Register shutdown participants with a
Phaseras beans are stopped, including their dependents. Keep one coordinator registered until all stop calls have been issued so synchronous callbacks cannot end the wait early. Phase timeouts and interruption handling are preserved.Regression tests defer either the higher-phase or the dependent bean's callback and verify that shutdown waits. Another test verifies that a dependent bean cannot prevent shutdown after the configured timeout.
Validation:
:spring-context:checkpasses. All 27DefaultLifecycleProcessorTestspass with-PtestGroups=LONG_RUNNING. Enabling that group for the whole module exposes two failures inBackgroundBootstrapTests.bootstrapWithCustomExecutorAndLazyConfigandEnableSchedulingTests.withExplicitScheduler; both reproduce on unmodified main at93ff61fb1f.