-
Notifications
You must be signed in to change notification settings - Fork 66
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
Correctly check nullability when reading from JSON objects #1809
Conversation
1882a49
to
36ea4f2
Compare
@@ -20,22 +20,27 @@ private const val PARSING_ERROR = "PARSING_ERROR" | |||
|
|||
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | |||
fun JSONObject.getStringOrNull(key: String): String? { | |||
return if (has(key)) getString(key) else null | |||
return if (!isNull(key)) getString(key) else 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.
We don't have tests for these functions. Can we add some tests so we know if something gets broken in the future?
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.
We can indeed, the problem is that the bug we found cannot be reproduced in tests :/ I will add some anyway.
COAND-994
COAND-994
36ea4f2
to
6a29028
Compare
✅ No public API changes |
Quality Gate passedIssues Measures |
Description
Replace
JSONObject.has
with!JSONObject.isNull
when reading JSON values to ensure correct handling of null values.Checklist
COAND-994