Skip to content

Apply never-reset-nested-types to writable properties - #1740

Open
kdelay wants to merge 1 commit into
spring-cloud:mainfrom
kdelay:fix/never-reset-nested-writable
Open

Apply never-reset-nested-types to writable properties#1740
kdelay wants to merge 1 commit into
spring-cloud:mainfrom
kdelay:fix/never-reset-nested-writable

Conversation

@kdelay

@kdelay kdelay commented Sep 12, 2026

Copy link
Copy Markdown

resetProperties applied the spring.cloud.refresh.never-reset-nested-types exclusion 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 is null when 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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants