-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Fix the issue in MappingJackson2MessageConverter where deserializatio… #33714
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
Conversation
…n returns null values for POJOs that do not have @JSONVIEW annotations.
@cooperlyt Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@cooperlyt Thank you for signing the Contributor License Agreement! |
Could you please share the original use case that ended-up passing this |
I Use Spring Cloud Stream connect to RabbitMQ, send a Json message, that happened on customer |
I would need a reproducer since I am not sure the use case is valid, it could be a Spring Cloud Stream bug. Please attach a zip archive or comment with a link to a repository that allow to reproduce this use case. |
the case need a RabbitMQ, Can I provide a docker-compose.yml |
Sure |
A test case Project just run add RabbitMQ docker-compose.yml |
Thanks for the reproducer, I will have a look. |
Looks like https://github.com/spring-cloud/spring-cloud-function is using the @olegz Can you elaborate on this? I think I understand the intent, but that's not a supported use case so far unless I am mistaken. |
Consider the following Function
with the following payload as input
If we don't provide/use So, aside form passing a |
And with regard to the original issue, i don't understand why @cooperlyt needs to register custom message converter - @sdeleuze feel free to push this issue to s-c-stream/function if you determine it's on us. |
@cooperlyt Can you please elaborate on what @olegz asked? |
Sorry for the late reply. Let me explain the reasons: First, after Spring Boot 3.3.X, if I don't register a custom JSON converter, it won't be applicable to any other converters. For example, in my sample program, if I remove the registration of Second, I need to make some custom settings to the ObjectMapper, such as registering some custom modules. |
I checked the code of JsonMessageConverter, and it seems that it does not have the ability to deserialize from JSON byte[] to an object . Additionally, starting from Spring Boot 3.3.X, it appears that the original JSON conversion done in the Stream RabbitMQ module has been deprecated, with the output fixed as byte[] and handed over to the converter to handle the deserialization of the payload. but To solve this problem, it seems there are two options: one is to enable MappingJackson2MessageConverter to correctly handle the deserialization of the payload (which is the goal of my PR), and the other is to give JsonMessageConverter the ability to deserialize JSON byte[] to an object! Am I misunderstanding anything? |
@olegz I am open to evolve |
@sdeleuze I would love if such support was provided at the core and somewhat surprised that it has never came up especially in the context of Spring Messaging |
@cooperlyt I don't understand what you mean when you say Also, customisations to But as I said, a reproducible sample would help |
@cooperlyt Indeed there was an issue in spring-cloud-function 4.1.3 with the way we create
. . . and you should be fine. |
@cooperlyt we'll have a 4.1.4 release on November 12 |
@cooperlyt Please test with the version shared by Oleg and confirm I can close this PR unmerged. |
Thanks |
Fix the issue in MappingJackson2MessageConverter where deserialization returns null values for POJOs that do not have
@JsonView
annotationsWhen a POJO does not have the JsonView annotation set, and Jackson's DEFAULT_VIEW_INCLUSION is false (the default value in Spring framework #16793), deserialization fails and returns an object with all properties empty.
I added a test in
MappingJackson2MessageConverterTests
that will fail before I fix it.PS: Discussion with jackson-databind issues.