Skip to content

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

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

kdelay wants to merge 1 commit into
spring-cloud:5.0.xfrom
kdelay:fix/never-reset-nested-writable

Conversation

@kdelay

@kdelay kdelay commented Sep 12, 2026

Copy link
Copy Markdown

spring.cloud.refresh.never-reset-nested-types (1c3d7b0, gh-1698) only takes effect on a property with no setter. A writable one is overwritten with the default instance's value in an earlier branch of resetProperties, before the exclusion is consulted, so it is still replaced on rebind and reads as null while the default leaves the field unset. That is gh-1727.

This consults the exclusion in the writable branch too, by declared type and by the runtime class. Nothing changes when the property is unset, and the reset stays best effort, as in gh-1733.

The test fails on main at 439ed3c (getWritable() is null after rebind) and passes with the fix. ./mvnw -pl spring-cloud-context verify: 234 tests, 0 failures, checkstyle and javaformat clean.

Scope is that escape hatch; a primitive cannot be listed in the property.

@ryanjbaxter

Copy link
Copy Markdown
Contributor

Can you submit this against the 5.0.x branch?

@kdelay
kdelay force-pushed the fix/never-reset-nested-writable branch from a42e9e6 to 4a4529b Compare September 16, 2026 00:43
@kdelay
kdelay changed the base branch from main to 5.0.x September 16, 2026 00:44
@kdelay

kdelay commented Sep 16, 2026

Copy link
Copy Markdown
Author

Retargeted to 5.0.x in 4a4529b. The commit cherry-picked cleanly. On 5.0.x the new test fails without the fix (AssertionError at ConfigurationPropertiesRebinderResetExclusionIntegrationTests.java:86) and passes with it; ./mvnw -pl spring-cloud-context verify gives 234 tests, 0 failures, 0 checkstyle violations.

@ryanjbaxter

Copy link
Copy Markdown
Contributor

Can you look at the failing PR build?

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>
@kdelay
kdelay force-pushed the fix/never-reset-nested-writable branch from 4a4529b to b362067 Compare September 17, 2026 01:37
@kdelay

kdelay commented Sep 17, 2026

Copy link
Copy Markdown
Author

The failure is a compile error in spring-cloud-loadbalancer, which this PR does not touch (the diff is spring-cloud-context only): reactor.cache and reactor.retry not found, both from reactor-extra.

I built unmodified 5.0.x (dd0d9f6) locally today: ./mvnw -pl spring-cloud-loadbalancer -am -DskipTests compile is BUILD SUCCESS, resolving reactor-extra 3.6.1, which has both packages. So the runner seems to have picked up a reactor-extra without them.

I pushed b362067, an identical tree to 4a4529b, for a fresh run; it needs a workflow approval.

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.

3 participants