Open dnijssen opened 1 month ago
Indeed JsonMapperConfiguration 4.1.2 vs 4.1.3 (diff here) makes CompositeMessageConverterFactory's json mapper registered modules differ:
4.1.2:
0 = "com.fasterxml.jackson.datatype.jdk8.Jdk8Module"
1 = "jackson-module-parameter-names"
2 = "jackson-datatype-jsr310"
3 = "com.fasterxml.jackson.module.kotlin.KotlinModule"
4 = "org.springframework.boot.jackson.JsonMixinModule"
5 = "org.springframework.boot.jackson.JsonComponentModule"
4.1.3:
0 = "jackson-datatype-jsr310"
So deserialization to kotlin does not work anymore. I have a sample using data classes and Bump spring-cloud-dependencies from 2023.0.2 to 2023.0.3 is failing
I've found other related issues here:
And a workaround here https://github.com/spring-cloud/spring-cloud-function/issues/1159#issuecomment-2225239377 🚀
Describe the bug In https://github.com/spring-cloud/spring-cloud-function/issues/1148 changes were made to construct a new
ObjectMapper
instance instead of using theObjectMapper
from application context. This causes many necessary modules are not registered anymore.For example I know get the following exception when trying to access a
Message<DTO>
(were DTO is a data class from Kotlin) payload (message.payload
) in a Spring Cloud Function using Spring Cloud Stream Binders (with aMessage<>
) ;But the underlying message/stacktrace in the
JacksonMapper
is as followed:Also as a Spring user I would expect the common
ObjectMapper
so it is used through out various components of Spring would just be used by Spring Cloud Function as well.Maybe instead of doing
new ObjectMapper()
which constructs a very "basic" jacksonObjectMapper
instance you can use theJackson2ObjectMapperBuilder
instead, which can (and is already by Spring Framework) customized in various ways. E.g. to check if Kotlin is present and if so add the missingKotlinModule
.