-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
@ConfigurationProperties no longer works on a mutable Kotlin data classes #34500
Comments
I (probably) hit the same issue when upgrading to 3.0.4. Had a Kotlin data class with @Bean
@ConfigurationProperties("event-hubs.producer")
fun eventHubProducerProperties() = EventHubProducerProperties() In 3.0.0 this didn't work, then in 3.0.2 it did, and now in 3.0.4 it doesn't work again. I stepped through it with a debugger: there are two instances created, one gets the properties injected, but the other one is used for the rest of the application context. |
@Azbesciak You sample has the |
@hho I expect your problem is similar. If you define a If that doesn't work, please provide a sample that I can take a look at. |
@philwebb thank you for the quick reply. If it is permanent, I need to know that, but... you know, legacy, backward compatibility... not a good way to introduce in a patch release. Not a good way at all since it was working like this for as long as I remember, and it occurs even in tutorials. |
Sorry, I think I messed up. I assumed that Kotlin data classes were immutable, but it looks like they can have setters. I'll need to change this logic Line 109 in 285097d
|
As I remember they can be immutable in spring boot, and still it is possible to use them as properties with But yes, in general, Kotlin data class can be mutable. |
OK, I took an hour to minimize my repro, and now I'm four minutes late 😄 Thank you both! |
@wilkinsona Sorry, but I think that title is slightly misleading: The current issue affects all mutable data classes used with |
Hello, as in discusion on Gitter there is an issue after update from 3.0.3 to 3.0.4 with
@ConfigurationProperty
and@Component
on bean.Repro repo: https://github.com/Azbesciak/spring-3-configuration-prop-issue/tree/spring-boot-3.0.4-config-prop-component-issue (please notice branch
spring-boot-3.0.4-config-prop-component-issue
)I suppose it existed also in 3.0.0 (that repo contains the example I also reported - #33509)
@wilkinsona also mentioned #34407
The text was updated successfully, but these errors were encountered: