Closed teabot closed 8 years ago
Yes, sounds like a problem. Probably related to the fact that JSON does not express difference (since there's just textual representation), whereas binary formats typically do use different underlying encoding.
Is this not an issue for jackson-databind? It's not necessarily Avro specific, and the code in question resides in that project?
@teabot correct, may well belong in jackson-databind
. But it needs to be verified against one of backends that do have native float
type, so this repo should have something, although possibly smile
, cbor
and protobuf
need verifications too (since there is some interaction between components).
Fixed for 2.7.8 / 2.8.3. May take a while until released as 2.7.7 and 2.8.2 just went out few days ago.
When parsing JSON documents with a schema described by suitably annotated Java POJO classes, Jackson represents
float
values withDoubleNode
instances, notFloatNode
instances as might be expected. This causes problems with other downstream libraries that attempt to interpret the node tree. There are situations where they may callisFloat()
on the respective nodes, expecting it to returntrue
for nodes that were derived fromfloat
properties. However, in these circumstancesDoubleNode.isFloat()
is invoked yielding a return value offalse
and causing said libraries to raise an error.I believe I have traced this behaviour back to:
com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._fromFloat(...)
The last call to the
nodeFactory
returns aDoubleNode
not aFloatNode
. I wonder if this should instead be implemented in a similar manner to_fromInt(...)
like so:I am currently working around this by patching the downstream library to do something like this:
Reference: problem discussion on jackson-user