Relocate @ConstructorBinding to bind package and update default behavior
See original GitHub issueIn spring-cloud-kubernetes we have support for configdata, as such, much of the underlying code uses snippets likes these:
binder.bind("spring.cloud.kubernetes.config", ConfigMapConfigProperties.class)
which works.
But I am trying to change some code to move configs to records, so I have code that does this, for example:
AbstractConfigProperties.RetryProperties properties = binder.bind("spring.cloud.kubernetes.config.retry", AbstractConfigProperties.RetryProperties.class)
.orElseGet(AbstractConfigProperties.RetryProperties::new);
where AbstractConfigProperties.RetryProperties is a record. Unfortunately, this does not work and binding does not happen.
My limited knowledge of Binder functionality does not allow me to figure out how to do it, and if it is possible at all. 😦 I can’t provide a simple example here, but I could push the branch that I am currently working on and tell what test to run in order to reproduce this.
I am also not sure the name of the issue is appropriate, but after a few hours of debug I am inclined to think that JavaBeanBinder is the one responsible for this.
Thank you for looking into this.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)

Top Related StackOverflow Question
We spoke about this today and we’re going to look to see if we can move
@ConstructorBindingto thebindpackage and align the default behavior.You might also want to try the
bindOrCreatemethod rather than using.orElseGet(AbstractConfigProperties.RetryProperties::new). That method will deal with@DefaultValueannotations.