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
Currently, provided Kafka ObjectMapperSerializer (and certainly the JSON-B one, this needs to be checked), serializes a null object to the "null" String. This is perfectly valid and will work fine when deserializing via a JSON based deserializer.
However, the tombstone mechanism usually implemented in Kafka Connect to signal a deletion is based on null payloads.
Someone can also use a JSON based serializer and a String based deserializer (for components not needed the payload information to avoid the cost of serialization), this is a valid use case and in this case a payload with the "null" String will ends up with a non-null String for the null JSON.
So we need a way to control how the provided JSON serializers serialize nulls.
Implementation ideas
Have a way to override the default null handling mechanism to serialize null payload as a null byte[] instead of the "null" String. This is easy to implement on itself but we must enable this mechanism only if some Kafka serializer property is set.
The default null handling is compatible with a full JSON serializer / deserializer chain so it must be kept as is by default.
Introduce a io.quarkus.kafka.json.serializer.null-as-null property that, when enabled, serializes null as a null byte[] instead of the "null" String for null payload.
This will be a Kafka serializer config property not a Quarkus one.
The text was updated successfully, but these errors were encountered:
Description
Currently, provided Kafka
ObjectMapperSerializer
(and certainly the JSON-B one, this needs to be checked), serializes a null object to the"null"
String. This is perfectly valid and will work fine when deserializing via a JSON based deserializer.However, the tombstone mechanism usually implemented in Kafka Connect to signal a deletion is based on null payloads.
Someone can also use a JSON based serializer and a String based deserializer (for components not needed the payload information to avoid the cost of serialization), this is a valid use case and in this case a payload with the
"null"
String will ends up with a non-null String for the null JSON.So we need a way to control how the provided JSON serializers serialize nulls.
Implementation ideas
Have a way to override the default null handling mechanism to serialize null payload as a null byte[] instead of the
"null"
String. This is easy to implement on itself but we must enable this mechanism only if some Kafka serializer property is set.The default null handling is compatible with a full JSON serializer / deserializer chain so it must be kept as is by default.
Introduce a
io.quarkus.kafka.json.serializer.null-as-null
property that, when enabled, serializes null as a null byte[] instead of the"null"
String for null payload.This will be a Kafka serializer config property not a Quarkus one.
The text was updated successfully, but these errors were encountered: