For what it's worth, I did hit a similar bug today.

I have some values coming from a third-party stats library that default in 
some cases to Double.NaN until they've got enough data to calculate them. 
Then I have some other stuff which is sending currency-precision floating 
point in the JSON.

I was feeding it through a Jackson + Jersey stack, and hitting this error, 
after I had enabled USE_BIG_DECIMAL_FOR_FLOATS for preserving the accuracy 
of the currency-precision data.

For me, it would definitely help on my side if I had a way to generate JSON 
with +inf, -inf, NaN, and currency-precision / BigDecimal with a single 
ObjectMapper registered to Jersey + Grizzly.

Right now I don't think this is possible.

Matthew.

On Monday, November 30, 2015 at 12:38:16 PM UTC-8, Tatu Saloranta wrote:
>
> (for a background, see 
> https://github.com/FasterXML/jackson-databind/issues/1028)
>
> One problem with Java number handling is that where float and double can 
> handle "non-numeric" values like infinity and general NaN (from division by 
> zero etc), the same is unfortunately not true for BigDecimal.
> For example see:
>
> http://stackoverflow.com/questions/28065158/java-bigdecimal-and-double-nan
>
> Given this, there is the problem with possible coercion of JSON values 
> into BigDecimal, and especially the case of having to convert Double/Float 
> representation of NaN or +Infinity or -Infinity.
> To me, the main choices appear to be either:
>
> 1. Indicate the problem explicitly by throwing an exception (impossible 
> conversion), or
> 2. Quietly leave the numeric type as-is, and let caller deal with some 
> numbers being BigDecimals, others Doubles.
>
> I can see why (2) may usually be preferable, but am bit concerned about 
> this leading to harder-to-track-down problems, and (1) providing earlier 
> indication of problems.
>
> I may be overstating the issues, however, so if you think (2) makes sense, 
> feel free to say so.
>
> -+ Tatu +-
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to