Apply never-reset-nested-types to writable properties - #1740
Open
kdelay wants to merge 1 commit into
Open
Conversation
resetProperties consulted the spring.cloud.refresh.never-reset-nested-types exclusion only in the branch that handles a property without a setter. A property that is writable took the first branch and was overwritten with the default instance's value before the exclusion was ever considered, so a type listed in that property was still replaced during a rebind. Where the default instance leaves the field unset, that value is null, and every reader of the bean sees null until the rebind completes. Check the exclusion for the writable branch too, against both the declared property type and the class of the current value. Signed-off-by: kdelay <kdelay20@gmail.com>
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.
resetPropertiesapplied thespring.cloud.refresh.never-reset-nested-typesexclusion only to a property with no setter. A writable property took the first branch and was overwritten with the default instance's value, so a listed type was still replaced on rebind. That value isnullwhen the default instance leaves the field unset, which is the failure in gh-1727.This checks the exclusion in the writable branch too, using the declared property type and the class of the current value. Nothing changes when the property is not configured.
The added test fails on
main(getWritable()is null after the rebind) and passes now../mvnw -pl spring-cloud-context verify: 234 tests, 0 failures; checkstyle and javaformat clean.Scope: this closes the gap in that escape hatch only, not the primitive case reported in the thread.