-
Notifications
You must be signed in to change notification settings - Fork 636
Description
Describe the bug
We are getting an error when consuming/deserializing a java object that contains less fields than the object sent by the producer.
This behavior started from Spring Cloud version 2023.0.1 and continues to be reproduced in version 2023.0.3.
We are getting the real problem when deserializing with Spring Cloud Stream Kafka a distributed traceability message that is being sent with zipkin via kafka sender, but the demo we show you reproduces the problem anyway.
Attached is a sample application in which the problem is reproduced: https://github.com/ferblaca/demoSCSKafka
The demo application consists of sending a ProductCompleteDTO
POJO with a Kafka producer configured with the Kafka client (without SCS) and two SCS Kafka consumers: one deserialising the message to ProductCompleteDTO
and the other to ProductSimpleDTO
(a subset of the ProductCompleteDTO object).
In Spring Cloud version 2023.0.0, both consumers correctly deserialize the message to their corresponding classes, but from version 2023.0.1-2023.0.3 onwards only the consumer that expects exactly the same object being sent consumes correctly.
This for us is a behavioural change that may be related to issue #1161.
Sample
https://github.com/ferblaca/demoSCSKafka
Steps to report the problem:
- Start the DemoStreamKafkaApplication.
- Check that the consumer
completeConsumer
consumes the sent message correctly. - Check for a ClassCastException error in the
simpleConsumer
.
The same application can be verified to work correctly by configuring version 2023.0.0
or by setting the application property demo.jackson.mapper.enabled: true
by which a custom JacksonMapper is configured.