Handle null values in KafkaStringHeaderReader (#16192)

This commit is contained in:
Aru Raghuwanshi 2024-03-23 00:35:55 -07:00 committed by GitHub
parent b0a9c318d6
commit 6e19ce5e69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,8 +48,11 @@ public class KafkaStringHeaderReader implements KafkaHeaderReader
public List<Pair<String, Object>> read()
{
List<Pair<String, Object>> events = new ArrayList<>();
for (Header hdr : headers) {
String s = new String(hdr.value(), this.encoding);
byte[] value = hdr.value();
String s = value == null ? null : new String(value, this.encoding);
String newKey = this.headerLabelPrefix + hdr.key();
events.add(Pair.of(newKey, s));
}