-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
2.17-rc1 UntypedObjectDeserializerNR/_deserializeFP() behaviour change with getNumberTypeFP() UNKNOWN #4410
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
Comments
Short: I think that pre-2.17 behavior was wrong (as in: not intended) and if I understand this correctly 2.17.0-rc1 works along what I think it should do. Fundamentally JSON has no notion of type for numbers, but for integral types we have actual limits to check for to select "minimal" type (chosen as But the original Addition of Now: If I understand your case correctly there is custom format parser backend, which had provided proper expected target type to use. You are correct in that I realize this is unfortunate wrt implementation requirement that is new and surprising: I must admit I was focused on format backends provided by Jackson project and did not consider external use cases, such as yours. Does this help? |
Come to think of this now, there probably would be a way to implement default As long as all backends that do NOT know the type (JSON, all textual format backends) override this with
things should then work. I am not 100% sure I have time to work on this, but present this idea if you had time to help? I will add explicit override for JSON backend now, fwtw ( |
Added overrides for all textual format backends: will see if I can add better defaulting for |
@matteobertozzi As per I changed |
Hi, Thanks for the explanation. It make sense. Also the default getNumberTypeFP() implementation from FasterXML/jackson-core#1235 works and brings the behaviour closer to what was before. (In my code i did the override of .getNumberTypeFP() with the same logic based on .numberType() )
In case of UntypedObjectDeserializerNR._deserializeFP() I don't see a rule for UNKNOWN that allow a custom implementation to decide what to do like .getNumberValue() does, and it defaults to double. |
What I mean by "default rules" means configuration settings to use for non-specific number target type (
this does not affect other cases like:
But yes, with default (vanilla) configuration settings, |
As to -> #4415 |
cool, thanks for your time and the detailed explanations. really appreciated! |
Describe your Issue
2.17 introduced .getNumberTypeFP() in JsonParser, which defaults to NumberTypeFP.UNKNOWN
when trying to run this code
with 2.16.1 everything is ok, with 2.17-rc1 the Float.class assert fails with Double.class
In 2.16.1 UntypedObjectDeserializerNR calls JsonParser.getNumberType() and the Parser is able to return FLOAT
without any changes to the parser 2.17-rc1 goes directly to JsonParser.getDoubleValue(), the _deserializeFP() does not consider the NumberTypeFP.UNKNOWN case and fallsback to .getDoubleValue()
https://github.com/FasterXML/jackson-databind/blob/2.17/src/main/java/com/fasterxml/jackson/databind/deser/std/UntypedObjectDeserializerNR.java#L358
so, it seems that with 2.17-rc1 every JsonParse must have to implement .getNumberTypeFP() to get the proper behaviour.
but I think that if we return .getNumberValue() when NumberTypeFP.UNKNOWN we get back to the behaviour we have in 2.16.
What do you think?
The text was updated successfully, but these errors were encountered: