-
Notifications
You must be signed in to change notification settings - Fork 682
KotlinBeanInfoFactory
fails on bean where setter is primitive type and getter is boxed
#2993
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
Comments
Nota bene, this is not a change introduced by the Kotlin upgrade. I only upgraded because one spring-boot dependency required it. The same signatures are generated by Kotlin |
Sorry, I forgot the original stacktrace, apologies 😊 :
|
That is expected as Spring is based on the Java Beans spec. Getters and setters must use the same type. We introduced the factory to reliably determine Kotlin properties as the various compilation and usage patterns in Kotlin would otherwise introduce a complexity that we wouldn't be able to handle. |
Well... First of all, this worked before, only Spring Boot 3.2.0 breaks it (this is a several years old project, this worked before, even with 3.1.3). |
The only alternatives we have is excluding these properties from property inspection or deciding which side of the property we want to add (the reading or the writing one). Generally speaking, the issue is not Spring but Kotlin's way to do things that then do not comply with standards that predate Kotlin by 15 years. Previously, the |
KotlinBeanInfoFactory
fails on bean where setter is primitive type and getter is boxed
We now skip adding asymmetric Kotlin properties if the getter returns a different type than the setter (e.g. due to value boxing). Closes #2993
We now skip adding asymmetric Kotlin properties if the getter returns a different type than the setter (e.g. due to value boxing). Closes #2993
We now skip adding asymmetric Kotlin properties if the getter returns a different type than the setter (e.g. due to value boxing). Closes #2993
That's addressed now in |
Thanks, I will try it tomorrow in the morning. |
Hmm, my gradle build fails with |
You need to add an entry for |
Ok it does not fail anymore. |
I have a bean that worked before (spring-boot
3.1.3
and Kotlin1.7.21
), but does not work with3.2.0
(and Kotlin1.9.21
).The following code reproduces this issue (edited down to only show relevant parts):
The
end
property above compiles down to the following pair of getter and setter (taken fromjavap
output):So this ends up in
KotlinBeanInfoFactory
as a call topds.add(new PropertyDescriptor(property.getName(), getter, setter));
. At this point the getter ispublic java.lang.Long MyEntity.getEnd()
and the setter isprotected void MyEntity.setEnd(long)
. This call finally ends up injava.beans.PropertyDescriptor.findPropertyType@L678
, where the testif (propertyType != null && !params[0].isAssignableFrom(propertyType))
fails with aIntrospectionException("type mismatch between read and write methods")
. The reason is thatisAssignableFrom
fails on comparinglong
andjava.lang.Long
.The text was updated successfully, but these errors were encountered: