NIFI-6824 - Handling NPE of header value when consuming from Kafka

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #3859.
This commit is contained in:
Matthew Formosa 2019-10-30 14:55:33 +01:00 committed by Pierre Villard
parent 67fca6832a
commit 4b08cf116c
No known key found for this signature in database
GPG Key ID: BEE1599F0726E9CD
3 changed files with 9 additions and 6 deletions

View File

@ -497,8 +497,9 @@ public abstract class ConsumerLease implements Closeable, ConsumerRebalanceListe
for (final Header header : consumerRecord.headers()) {
final String attributeName = header.key();
if (headerNamePattern.matcher(attributeName).matches()) {
attributes.put(attributeName, new String(header.value(), headerCharacterSet));
final byte[] attributeValue = header.value();
if (headerNamePattern.matcher(attributeName).matches() && attributeValue != null) {
attributes.put(attributeName, new String(attributeValue, headerCharacterSet));
}
}

View File

@ -497,8 +497,9 @@ public abstract class ConsumerLease implements Closeable, ConsumerRebalanceListe
for (final Header header : consumerRecord.headers()) {
final String attributeName = header.key();
if (headerNamePattern.matcher(attributeName).matches()) {
attributes.put(attributeName, new String(header.value(), headerCharacterSet));
final byte[] attributeValue = header.value();
if (headerNamePattern.matcher(attributeName).matches() && attributeValue != null) {
attributes.put(attributeName, new String(attributeValue, headerCharacterSet));
}
}

View File

@ -497,8 +497,9 @@ public abstract class ConsumerLease implements Closeable, ConsumerRebalanceListe
for (final Header header : consumerRecord.headers()) {
final String attributeName = header.key();
if (headerNamePattern.matcher(attributeName).matches()) {
attributes.put(attributeName, new String(header.value(), headerCharacterSet));
final byte[] attributeValue = header.value();
if (headerNamePattern.matcher(attributeName).matches() && attributeValue != null) {
attributes.put(attributeName, new String(attributeValue, headerCharacterSet));
}
}