Recreate proxied @ConfigurationProperties beans on rebind by seonghyeoklee · Pull Request #1662 · spring-cloud/spring-cloud-commons (original) (raw)
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
- Unwrap freshBean if createBean() returns an AOP proxy to avoid double-proxied targets where advice executes twice
- Create fresh instance before destroying old target so a failure in createBean()/setTargetSource() does not leave the proxy pointing at an already-destroyed target
- On setTargetSource failure, destroy freshBean before rethrowing
Signed-off-by: seonghyeoklee dltjdgur327@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
[ Show hidden characters]({{ revealButtonHref }})