You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In #1148 changes were made to construct a new ObjectMapper instance instead of using the ObjectMapper 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 a Message<>) ;
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.example.DTO (java.lang.String is in module java.base of loader 'bootstrap'; org.example.DTO is in unnamed module of loader 'app')
But the underlying message/stacktrace in the JacksonMapper is as followed:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.example.DTO` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 15]
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" jackson ObjectMapper instance you can use the Jackson2ObjectMapperBuilder 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 missing KotlinModule.
The text was updated successfully, but these errors were encountered:
Describe the bug
In #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
.The text was updated successfully, but these errors were encountered: