-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix NPE when printing records with empty value (MINOR) #3470
Conversation
@@ -179,7 +180,9 @@ public String print(final ConsumerRecord<String, Bytes> record) | |||
|
|||
objectNode.put(SchemaUtil.ROWTIME_NAME.name(), record.timestamp()); | |||
objectNode.put(SchemaUtil.ROWKEY_NAME.name(), key); | |||
objectNode.setAll((ObjectNode) jsonNode); | |||
if (jsonNode != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix isn't necessary since the above addition (on line 71) takes care of it, but I figure the redundancy can't hurt since we don't want to hit an NPE if something else we don't know about slips through?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer omitting this fix because jsonNode being null could be a symptom for a different issue (assuming we expect it to be non-null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @vcrfxia
@@ -179,7 +180,9 @@ public String print(final ConsumerRecord<String, Bytes> record) | |||
|
|||
objectNode.put(SchemaUtil.ROWTIME_NAME.name(), record.timestamp()); | |||
objectNode.put(SchemaUtil.ROWKEY_NAME.name(), key); | |||
objectNode.setAll((ObjectNode) jsonNode); | |||
if (jsonNode != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer omitting this fix because jsonNode being null could be a symptom for a different issue (assuming we expect it to be non-null)
Description
Fixes #3450.
Currently when
print topic
encounters a JSON record with an empty value, a NullPointerException is thrown:This PR fixes the NPE by skipping the record, as we currently do for records with null value.
Testing done
Unit test + manual.
Reviewer checklist