-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
StdDeserializer
coerces ints to floats even if configured to fail
#3503
Comments
Hmmh. Interesting question -- does "coercion" mean forceful explicit change that is not allowed by default like in Java -- in which case Integral numbers can become Floating-point ones since there is no loss of accuracy (... except for possible overflow?) -- or should it also include this case? So, the reason this is not checked is as per above: whereas conversion from integer number to floating point is likely dangerous, the reverse typical is not. But I think it is not unreasonable to expect one could consider this a coercion too, something that can be prevented. So if anyone has time and interest to work on a PR to add support, I'd be happy to help |
Friday evening seemed like the perfect moment to work on some open-source and give this a shot. I sent in a PR. Let me know what you think. |
Thank you! I really appreciate this & hope to look into it soon. |
StdDeserializer
coerces ints to floats even if configured to fail
Describe the bug
Coercion configuration makes it possible to configure int-to-float coercions to fail. The
StdDeserializer
class, however, coerces floats to ints regardless of the coercion config. In fact, the_parseFloatPrimitive
method makes no distinction between ints and floats.jackson-databind/src/main/java/com/fasterxml/jackson/databind/deser/std/StdDeserializer.java
Lines 986 to 988 in 0b7d89b
Version information
2.13.2
To Reproduce
The test fails.
Expected behavior
As specified in the unit test, I would expect
readValue
to throw some type ofMismatchedInputException
exception.Additional context
The text was updated successfully, but these errors were encountered: