spring-cloud / spring-cloud/spring-cloud-commons
ConfigurationPropertiesRebinder not compatible with @ConstructorBinding when constructed in bootstrap
@spencergibb is already working on this.
Since Mar 30, 2021.
- Dominant language
- Java
- Stars
- 751
- Forks
- 744
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
Using Hoxton.SR8
If you define an @ConfigurationProperties class that uses @ConstructorBinding, attempts to rebind it using ConfigurationPropertiesRebinder will fail with an exception from ConfigurationPropertiesBindingPostProcessor: ""Cannot bind @ConfigurationProperties for bean XXXX Ensure that @ConstructorBinding has not been applied to regular bean"
This is especially problematic because Spring Cloud Context rebinds all ConfigurationProperties classes that have been used in the bootstrap context in order to ensure that property changes during the bootstrap phase are picked up. Looking at the code, it's not clear to me that there's a simple fix for this: the rebinder fundamentally assumes that the properties bean is mutable. In order to support immutable properties classes I guess it would need some sort of proxy in the middle to allow the properties bean to be re-constructed without having to reinject it into every dependent bean.
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.
Assessment
This issue has not been assessed yet.