mosermw commented on code in PR #7760:
URL: https://github.com/apache/nifi/pull/7760#discussion_r1337696932
##########
nifi-commons/nifi-flowfile-packager/src/main/java/org/apache/nifi/util/FlowFilePackagerV3.java:
##########
@@ -36,8 +36,8 @@ public void packageFlowFile(final InputStream in, final
OutputStream out, final
} else {
writeFieldLength(out, attributes.size()); //write out the number
of attributes
for (final Map.Entry<String, String> entry :
attributes.entrySet()) { //write out each attribute key/value pair
- writeString(entry.getKey(), out);
- writeString(entry.getValue(), out);
+ writeString(entry.getKey() == null ? "" : entry.getKey(), out);
Review Comment:
I don't think the NiFi framework allows null for an attribute key. However,
the Java HashMap allows a null key. I felt that FlowFilePackagerV3 is generic
enough that it could be used in unit tests where the framework isn't present to
enforce that restriction. Essentially, I changed this line to be safe in "you
never know" situations.
I thought of not outputting an attribute with a null key at all, but that
would throw off the number of attributes written by `writeFieldLength` on line
37.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]