Fixes #16 : Handle null values gracefully#34
Merged
GurtejSohi merged 1 commit intomainfrom Mar 5, 2021
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## main #34 +/- ##
============================================
+ Coverage 90.50% 90.52% +0.02%
Complexity 109 109
============================================
Files 14 14
Lines 400 401 +1
Branches 18 18
============================================
+ Hits 362 363 +1
Misses 32 32
Partials 6 6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
GurtejSohi
commented
Mar 5, 2021
| Value nullValue = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build(); | ||
| ConfigDocument configDocument = new ConfigDocument(RESOURCE_NAME, RESOURCE_NAMESPACE, | ||
| TENANT_ID, DEFAULT_CONTEXT, 15, "user1", nullValue, timestamp, timestamp); | ||
| assertEquals(configDocument, ConfigDocument.fromJson(configDocument.toJson())); |
Collaborator
Author
There was a problem hiding this comment.
This assertion fails without the above changes in ConfigDocument as in that case, the config document - ConfigDocument.fromJson(configDocument.toJson()) would have config value as null.
aaron-steinfeld
approved these changes
Mar 5, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #16
Serialization of
NULL_VALUE(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()) yields the string - "null", which when deserialized was previously returning the Value asnull. Although, we handlenullalso using the isNull() method (which is why it wasn't affecting the client), we also log an error saying that it is unexpected because ideally, we shouldn't be working withnull- instead we should be using the null placeholder -NULL_VALUE.So, this change tells the
JsonDeserializerto use the null placeholder (NULL_VALUE) on encountering the string - "null", which ensures that we never getnullconfig on deserialization.Testing
Added unit test
Checklist: