Repository navigation
Bind a fresh instance before resetting a rebound bean - #1781
Merged
ryanjbaxter merged 1 commit intoNov 2, 2026
Merged
ryanjbaxter merged 1 commit into
ryanjbaxter merged 1 commit into
Conversation
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.
Fixes #1727
Since 5.0.2 (#1680), ConfigurationPropertiesRebinder resets the live
@ConfigurationPropertiesbean to its class-level defaults and only then re-binds it. Between those two steps a concurrent reader sees the unbound state@Autowired) would be copied onto the live bean as null and reopen the window.Known limitation:
The bean is initialized again after the copy, and Spring Boot's CollectionBinder.merge updates an existing, modifiable collection by clearing it and adding the bound elements. A collection property that has a value in the Environment can therefore still be briefly empty during a rebind. Maps are not affected. This is documented in the reference docs and the class Javadoc. Addressing this that would mean re-implementing initializeBean without the binding post-processor, which is not something I think we should do.