Affects: 5.3.9


With kotlinx.serialization and Jackson (because of actuator) on the classpath, if a collection such as a List<T> is serialized as the response, Jackson will be used instead of kotlinx.serialization. This can cause problems if using @SerialName since Jackson will ignore those.

This only applies if the collection itself is intended to be the response body, so if a @Serializable class contains a collection it will still be serialized normally using kotlinx.serialization.

Comment From: xuanswe

If I understand correctly, even if we configure to use kotlinx.serialization, Spring still needs Jackson in dependencies.

Could someone please explain why? when Jackson must be used instead of kotlinx? and how to check which one is using? Is there a plan to completely remove Jackson if using kotlinx?

Currently, if I remove Jackson and return a List<String>, I will get 406 Not Acceptable error.

Sorry for too many questions.

Comment From: sdeleuze

Hi, sorry for the delay.

Based on kotlinx.serialization source code, I would expect serialization work as expected with List and Collection (not Iterable) of generic types annotated by @Serializable.

If you are trying to serialize a thitrd party interface, you may be blocked by https://github.com/Kotlin/kotlinx.serialization/issues/2060 but that one is not on Spring side.

Could you please provide a repro?

Comment From: xuanswe

@sdeleuze thanks for pointing to the relevant ticket!

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.