Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigurationPropertiesRebinder doesn't rebind properties for a bean which was created during bootstrap phase #1220

Open
pitagoras3 opened this issue Mar 20, 2023 · 0 comments

Comments

@pitagoras3
Copy link

pitagoras3 commented Mar 20, 2023

Bug description

Version of spring-cloud-commons: 3.1.5 (in lower versions of spring-cloud-commons this bug doesn't occur)
Version of spring-boot: 2.7.9 (irrelevant)

When a bean using @ConfigurationProperties is created during bootstrap phase with values taken from bootstrap.yaml file, then the values of this bean's fields are not updated with properties fetched using spring-cloud.

Sample

I've created a repository which reproduces this bug: https://github.com/pitagoras3/spring-cloud-context-bug.

In this project, you can find a test SpringCloudContextBugApplicationTests.shouldNotFailToUpdateApplicationPropertiesBean which fails, when springCloudCommons version is >= 3.1.5.

Where is the problem?

After some debugging I've found out that rebind method in ConfigurationPropertiesRebinder had changed between versions 3.1.4 and 3.1.5. In my opinion the bug which I have described might be a side-effect of this specific change. In 3.1.5 version of spring-cloud-context my IncorrectProperties bean used in test is never destroyed and initialized again (as it was in version 3.1.4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants