question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relocate @ConstructorBinding to bind package and update default behavior

See original GitHub issue

In 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:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
philwebbcommented, Oct 13, 2022

We spoke about this today and we’re going to look to see if we can move @ConstructorBinding to the bind package and align the default behavior.

1reaction
philwebbcommented, Oct 11, 2022

You might also want to try the bindOrCreate method rather than using .orElseGet(AbstractConfigProperties.RetryProperties::new). That method will deal with @DefaultValue annotations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Core Features - Spring
This section dives into the details of Spring Boot. Here you can learn about the key features that you may want to use...
Read more >
BIND and REBIND options for packages, plans, and services
A default of existing value for REBIND PLAN or REBIND PACKAGE means that the default is the value that was determined during the...
Read more >
SwiftUI: How to implement a custom init with @Binding variables
I am working on a money input screen and I need to implement a custom init to set a state variable based on...
Read more >
Binder (Guice 4.2 API) - Google
bind (ServiceImpl.class); This statement does essentially nothing; it "binds the ServiceImpl class to itself" and does not change Guice's default behavior. You ...
Read more >
SerializedObject data binding - Unity - Manual
's name property, which is m_Name , set the binding path to m_Name . You can set the binding path in UI Builder,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found