opwvhk commented on code in PR #2529:
URL: https://github.com/apache/avro/pull/2529#discussion_r1342549444
##########
lang/java/avro/src/main/java/org/apache/avro/util/internal/JacksonUtils.java:
##########
@@ -136,10 +137,23 @@ public static Object toObject(JsonNode jsonNode, Schema
schema) {
return jsonNode.asDouble();
}
} else if (jsonNode.isDouble() || jsonNode.isFloat()) {
- if (schema == null || schema.getType().equals(Schema.Type.DOUBLE)) {
- return jsonNode.asDouble();
- } else if (schema.getType().equals(Schema.Type.FLOAT)) {
- return (float) jsonNode.asDouble();
+ if (schema != null) {
+ if (schema.getType().equals(Schema.Type.DOUBLE)) {
+ return jsonNode.doubleValue();
+ } else if (schema.getType().equals(Schema.Type.FLOAT)) {
+ return jsonNode.floatValue();
+ }
+ } else if (jsonNode.isDouble()) {
+ return jsonNode.doubleValue();
+ } else if (jsonNode.isFloat()) {
Review Comment:
We can drop this, given the if-statement in line 139.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]