Skip to content

Recreate proxied @ConfigurationProperties beans on rebind#1662

Open
seonghyeoklee wants to merge 1 commit intospring-cloud:mainfrom
seonghyeoklee:fix/rebind-restore-field-initializers
Open

Recreate proxied @ConfigurationProperties beans on rebind#1662
seonghyeoklee wants to merge 1 commit intospring-cloud:mainfrom
seonghyeoklee:fix/rebind-restore-field-initializers

Conversation

@seonghyeoklee
Copy link

Summary

When a @ConfigurationProperties bean is wrapped in an AOP proxy and properties are removed from the Environment, calling rebind() previously left field initializers unrestored (they became null / 0 / false instead of their declared default values).

This change modifies ConfigurationPropertiesRebinder.rebind() so that when the bean is an AOP proxy, a fresh instance is created via createBean() and the proxy's TargetSource is replaced, ensuring field initializers are properly restored.

Non-proxied beans continue to use the existing destroyBean() + initializeBean() behavior for backwards compatibility.

Fixes gh-1616

Changes

  • ConfigurationPropertiesRebinder: detect proxied beans and replace the proxy target with a freshly created instance
  • Added ConfigurationPropertiesRebinderFieldInitializerIntegrationTests to verify field initializer restoration

@ryanjbaxter
Copy link
Contributor

Can you sign the commits so the DCO passes?

When a @ConfigurationProperties bean is wrapped in an AOP proxy,
recreate the target instance via createBean() instead of re-initializing
the existing one. This ensures field initializers are restored when
properties are removed from the Environment.

Fixes spring-cloudgh-1616

Signed-off-by: seonghyeoklee <dltjdgur327@gmail.com>
@seonghyeoklee seonghyeoklee force-pushed the fix/rebind-restore-field-initializers branch from f8fab9b to 49a9ec2 Compare March 12, 2026 01:10
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.

ConfigurationProperties initial values not restored on DELETE /actuator/env

3 participants