-
Notifications
You must be signed in to change notification settings - Fork 213
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
Check Double NaN and Infinity Values #752
Conversation
Codecov Report
@@ Coverage Diff @@
## master #752 +/- ##
==========================================
+ Coverage 81.36% 81.38% +0.01%
==========================================
Files 34 34
Lines 2866 2869 +3
Branches 342 344 +2
==========================================
+ Hits 2332 2335 +3
Misses 420 420
Partials 114 114
Continue to review full report at Codecov.
|
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 suggested a slight change, but overall looks 🔥
@@ -212,6 +212,10 @@ private static void writeValue(Object value, JsonWriter writer) throws IOExcepti | |||
if (value == null) { | |||
writer.nullValue(); | |||
} else if (value instanceof Number) { | |||
if (value instanceof Double | |||
&& (Double.isNaN((Double) value) || Double.isInfinite((Double) value))) { | |||
value = 0; |
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.
lets make the value explicity 0.0
, to conform to a double value
@@ -298,6 +298,27 @@ class CartographerTest { | |||
) | |||
} | |||
|
|||
@Test | |||
@Throws(IOException::class) | |||
fun encodesInfiniteAndNanDoubles() { |
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.
🔥
NaN vales are being added to our JSON payload resulting in the entire payload failing. Check for these vales and now set to zero.