spring-cloud/spring-cloud-function

Deserialization problem with Spring Cloud Stream & Spring Cloud Function

mfrechePgest opened this issue · 8 comments

Describe the issue

Since Spring Cloud 2023.0.3, most of our Spring Cloud Stream bindings are failing to deserialize JSON objects.
It seems Jackson property DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES is now enabled by default.
It wasn't the case in 2023.0.2.

If I send in my message queue a JSON object with more fields than the DTO knows about : it fails during deserialization.

To Reproduce
Here is a sample repo where problem is shown.
There are 2 branches with each Spring Cloud version.

You can execute MessagingStreamsIT.
Every test runs fine in 2023.0.2 branch, while it fails in 2023.0.3.

As it's shown in some tests, adding @JsonIgnoreProperties(ignoreUnknown = true) on every DTO object seems to be a workaround.

Indeed we just added it to solve another issue. i will take a look and see what we can do

Here is the issue where it was introduced - #1097

Actually i take this back, the only deserialisation feature we have currently is mapper.configure(DeserializationFeature.FAIL_ON_TRAILING_TOKENS, true);.
Where do you see it being set?

I didn't, actually

Symptoms are just "as if" this property was forced under the hood.

Let me try your sample

I see the issue. It's in s-c-function. I will transfer it there and push the fix shortly

Seems like PR #1162 addressed the same issue in a diffrent way too

@olegz This fix doesn't resolve the problem of not all modules being registered. For instance the Kotlin-Module is not registered and that leads to problems when using Kotlin (data classes).