-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Milestone
Description
In what version(s) of Spring for Apache Kafka are you seeing this issue?
3.0.11
Describe the bug
Unable to send null message through KafkaTemplate#send(Message)
.
Unable to create GenericMessage
with null payload.
To Reproduce
spring:
kafka:
producer:
value-serializer: org.apache.kafka.common.serialization.ByteArraySerializer
@Bean
public RecordMessageConverter jsonMessageConverter(ObjectMapper objectMapper) {
return new ByteArrayJsonMessageConverter(objectMapper);
}
final var Object myValue = null;
final var message = MessageBuilder.withPayload(myValue).setHeader(TOPIC, topic).build();
kafkaTemplate.send(message);
Expected behavior
Kafka sends null message.
But we get: IllegalArgumentException: Payload must not be null
We could set myValue=KafkaNull.INSTANCE;
But JsonMessageConverter inherited classes cannot proccess KafkaNull.