-
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.7
Describe the bug
When deserialize() method is called with a null (bytes) message a NullPointerException is thrown. This is thrown from the line that attempts to create a new String from the bytes:
@Override
public T deserialize(String topic, Headers headers, byte[] data) {
return this.parser.apply(new String(data, this.charset), headers);
}
To Reproduce
Publish a null value to a kafka topic where the consumer uses ParseStringDeserializer for deserialization (e.g. via ToFromStringSerde).
Expected behavior
Underlying 'parser' function expected to be invoked with null String value. This expectation is supported by the javadoc on Deserializer interface (that ParseStringDeserializer implements).
/**
* Deserialize a record value from a byte array into a value or object.
* @param topic topic associated with the data
* @param headers headers associated with the record; may be empty.
* @param data serialized bytes; may be null; implementations are recommended to handle null by returning a value or null rather than throwing an exception.
* @return deserialized typed data; may be null
*/
default T deserialize(String topic, Headers headers, byte[] data) {
return deserialize(topic, data);
}