spring-cloud / spring-cloud/spring-cloud-commons
ConfigurationPropertiesRebinder doesn't rebind properties for a bean which was created during bootstrap phase
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 751
- Forks
- 744
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with spring-cloud-context/src/main/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinder.java and the reproduction test SpringCloudContextBugApplicationTests.shouldNotFailToUpdateApplicationPropertiesBean. Compare the rebind behavior between spring-cloud-commons 3.1.4 and 3.1.5, then run the referenced test. Done means the bootstrap-created @ConfigurationProperties bean receives the fetched Spring Cloud values without breaking existing rebinding behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100