opwvhk commented on code in PR #2529:
URL: https://github.com/apache/avro/pull/2529#discussion_r1342550039


##########
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();
+        }

Review Comment:
   Is it possible to have a JSON node with a float/double, but a schema that is 
neither?



-- 
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]

Reply via email to