-
-
Notifications
You must be signed in to change notification settings - Fork 800
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
Improve detection of "is a NaN" to only consider explicit cases, not double
overflow/underflow
#1137
Comments
There is similar NaN checking in many Jackson modules. If we want to sort this for 2.16, we should delay the release to look at all the modules. I think NaN handling is a rarely needed use case and that it be better to leave this till after 2.16 release. |
If we were to tackle this, I would suggest adding isNaNOrInfinite(String) public static method to NumberInput class that does simple String checks instead of trying to parse the input as a number. This could be used in different Jackson modules. Most of our parsers keep the data as Strings/char[] and only parse to number representation if needed. |
Forgot to tag this as I don't have a complete idea on how to go about this, due to differences between Double/double/Float/float (with NaN marker values, but limited ranges) vs One existing example of what might be doable are methods
which would be roughly same as But then again there is the question of changing observed behavior of |
Was implemented a while ago (forgot to add reference from commit). Tested via src/test/java/com/fasterxml/jackson/core/read/NonStandardNumberParsingTest.java |
Currently it appears that too big (overflow) and too small (underflow) values can produce "Not a Number" (NaN) values from
JsonParser
, in addition to optionally supported tokens -- only allowed if enabled -- like+INF
/-INF
/NaN
).But doing this causes problem with
BigDecimal
handling since such "too big"/"too small" values CAN be represented asBigDecimal
, whereas "true" Not-a-Numbers cannot.So we should improve handling of
JsonParser.isNaN()
method so that it ONLY indicates explicit Not-a-Number cases, and not overflows.The text was updated successfully, but these errors were encountered: