-
Notifications
You must be signed in to change notification settings - Fork 38
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 #381] Fixing null pointer #382
base: develop/1.x
Are you sure you want to change the base?
Conversation
41b6aeb
to
6184705
Compare
Thank you for reporting and submitting a patch! This clearly fixes the issue for |
I filed a new commit that change the mutate. To be honest, I was lazy and did not want to search which mutate implementation I have to change. Now that you give me the clue, I have no excuse ;) |
if (newval != null) | ||
JsonNode newval = newobj.get(key); | ||
newval = mutation.apply(newval != null ? newval : NullNode.getInstance()); | ||
if (newval != null && !newval.isNull()) |
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.
JSON null
(NullNode) is a valid value for object fields, so && !newval.isNull()
is unnecessary.
$ jq -c '.foo += null' <<< '{}'
{"foo":null}
Other than that, the patch looks good 👍
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.
If I remove the isNull, a lot of test will fail (acutally it took me a while to figure out that). The reason is the same why you add the original null check, to prevent null values to be added to the object (you have some unit test to prevent that)
Fix #381