You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ConfigurationProperties initial values not restored on DELETE /actuator/env #1616
We are setting a configuration value via POST /actuator/env and later attempt to restore the original value by running DELETE /actuator/env.
However, this does not work — Spring does not restore the values defined in the field declaration.
changed the title [-]ConfigurationProperties initial values not restore on DELETE /actutaor/env[/-][+]ConfigurationProperties initial values not restored on DELETE /actutaor/env[/+]on Oct 24, 2025
changed the title [-]ConfigurationProperties initial values not restored on DELETE /actutaor/env[/-][+]ConfigurationProperties initial values not restored on DELETE /actuator/env[/+]on Oct 28, 2025
Thanks for reporting this issue, @david0. After investigating, I believe this is an expected behavior based on how Spring Boot's property binding works.
The issue is in Spring Boot's Binder class, not in Spring Cloud Config or Spring Cloud Commons.
When you call DELETE /actuator/env:
The "manager" property source is correctly removed from the Environment
ConfigurationPropertiesRebinder correctly triggers rebinding of your @ConfigurationProperties beans
However, the Binder uses Java default values (null, 0, false) when properties are absent - it never uses field initializers
Why Field Initializers Aren't Restored
Field initializers like this:
@ConfigurationProperties("my-properties")
classMyProperties {
privateStringname = "initial"; // Field initializer
}
Are only executed during object construction. During rebinding:
The bean is not recreated from scratch
Spring Boot only re-sets property values
The Binder has no access to field initializer values from your source code
When a property is absent, it uses Java defaults (null for objects, 0 for primitives)
While I agree that your analysis is correct I do not understand why it is accepted that this is "just the way how it is".
Its counter-intuitive and makes the use of field initialisers for @ConfigurationProperties questionable, as they will not handled correctly. At least that should be documented.
I also think it does not has to be this way, as a fresh bean could be created and the values could be copied over. Theoretically that would work and should at least be considered.
It is not something Spring Cloud can address since it is behavior of the Binder in Spring Boot so if the behavior needs to change, the change needs to be made in Spring Boot
I don't think Boot can do anything about this. Property rebinding is a Spring Cloud feature that Boot knows nothing about.
During rebinding:
The bean is not recreated from scratch
This is the crux of the problem. AFAIK, there's no way to replay a class's field initialisers on an existing instance. As a result, for rebinding to work reliably, the instance has to be recreated. For that to work, everywhere that the @ConfigurationProperties bean has been injected a proxy is required. Perhaps @RefreshScope can help here? Alternatively, perhaps Cloud can allow people to opt in to proxying of all @ConfigurationProperties beans when someone wants to use rebinding and then recreate the instance that's behind the proxy upon an EnvironmentChangedEvent.
Would it be acceptable to do copy over the values from the new bean to the old bean? At least that works correctly for me and is not as a big change as proxying?
Before I start, I'd like to confirm the preferred approach — should I go with the shallowCopyFieldState approach, or the proxy-based instance replacement that @wilkinsona mentioned?
Activity
[-]ConfigurationProperties initial values not restore on DELETE /actutaor/env[/-][+]ConfigurationProperties initial values not restored on DELETE /actutaor/env[/+][-]ConfigurationProperties initial values not restored on DELETE /actutaor/env[/-][+]ConfigurationProperties initial values not restored on DELETE /actuator/env[/+]ryanjbaxter commentedon Oct 29, 2025
Thanks for reporting this issue, @david0. After investigating, I believe this is an expected behavior based on how Spring Boot's property binding works.
The issue is in Spring Boot's
Binderclass, not in Spring Cloud Config or Spring Cloud Commons.When you call
DELETE /actuator/env:"manager"property source is correctly removed from the EnvironmentConfigurationPropertiesRebindercorrectly triggers rebinding of your@ConfigurationPropertiesbeansBinderuses Java default values (null, 0, false) when properties are absent - it never uses field initializersWhy Field Initializers Aren't Restored
Field initializers like this:
Are only executed during object construction. During rebinding:
Binderhas no access to field initializer values from your source codedavid0 commentedon Nov 6, 2025
While I agree that your analysis is correct I do not understand why it is accepted that this is "just the way how it is".
Its counter-intuitive and makes the use of field initialisers for
@ConfigurationPropertiesquestionable, as they will not handled correctly. At least that should be documented.I also think it does not has to be this way, as a fresh bean could be created and the values could be copied over. Theoretically that would work and should at least be considered.
ryanjbaxter commentedon Nov 7, 2025
It is not something Spring Cloud can address since it is behavior of the Binder in Spring Boot so if the behavior needs to change, the change needs to be made in Spring Boot
wilkinsona commentedon Nov 28, 2025
I don't think Boot can do anything about this. Property rebinding is a Spring Cloud feature that Boot knows nothing about.
This is the crux of the problem. AFAIK, there's no way to replay a class's field initialisers on an existing instance. As a result, for rebinding to work reliably, the instance has to be recreated. For that to work, everywhere that the
@ConfigurationPropertiesbean has been injected a proxy is required. Perhaps@RefreshScopecan help here? Alternatively, perhaps Cloud can allow people to opt in to proxying of all@ConfigurationPropertiesbeans when someone wants to use rebinding and then recreate the instance that's behind the proxy upon anEnvironmentChangedEvent.2 remaining items
david0 commentedon Jan 5, 2026
Nice to see that its considered again.
Would it be acceptable to do copy over the values from the new bean to the old bean? At least that works correctly for me and is not as a big change as proxying?
seonghyeoklee commentedon Mar 7, 2026
Hi, I'd like to work on this issue.
Before I start, I'd like to confirm the preferred approach — should I go with the
shallowCopyFieldStateapproach, or the proxy-based instance replacement that @wilkinsona mentioned?ryanjbaxter commentedon Mar 9, 2026
I would say the proxy approach would be my first choice I think
Recreate proxied @ConfigurationProperties beans on rebind
Recreate proxied @ConfigurationProperties beans on rebind