-
Notifications
You must be signed in to change notification settings - Fork 38.1k
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
Refine kotlinx.serialization support #26147
Comments
We should probably take advantage of Let's also make sure it allows both Jackson and Kotlin serialization to be used together is a Boot app with actuator as discussed in spring-projects/spring-boot#24238. |
I noticed also that error messages returned by the server too cannot be encoded when jackson is disabled, as described in this page When a request in forbidden in a REST controller the server sends back this: {"timestamp":"2020-11-25T22:29:58.573+00:00","status":403,"error":"Forbidden","message":"","path":"/user"} But when kotlinx-serialization is enabled and jackson disabled, the server resolved the request with this error:
Maybe the documentation could be updated in the meantime to specify that disabling jackson as said prevents internal messages from being serialized ? |
Yeah we probably need to advise (and maybe configure) both by default since Kotlin serialization is only for Kotlin classes annotated with |
Hi @sdeleuze , Migrating to Spring Boot 2.4.1, I encountered the following error while trying to deserialize JSON
In my projet we're using Java interfaces implemented by Java classes. I guess the issue comes from the KotlinSerializationJsonHttpMessageConverter.candRead method that returns true when the Type is a Java interface. But when the KotlinSerializationJsonHttpMessageConverter.read method is called then it fails because the concrete type is a Java class and not a Kotlin class. This is not blocking for me as I can change the converters order or just remove kotlinx-serialization (it's a transitive dependency I don't actually need). But I thought you might want to be aware of this behavior. |
@mickael-coquer Thanks for raising that, worth to fix IMO, could you please create a related issue? |
Here you go: #26298 |
Affects: 5.3.1
Bug
I'm using the kotlinx-serialization library. The library is properly set up, jackson is excluded from dependencies, and returning a class annotated with
@Serializable
works correctly.I'm trying to return a simple Kotlin list from a controller. When accessing the route the server displays this error and nothing is returned:
Error message
What I expected
I expected the list to be serialized properly like this:
Workarounds
Those three workarounds work:
The text was updated successfully, but these errors were encountered: