You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by dk...@apache.org on 2020/05/21 15:30:00 UTC

[avro] 01/03: AVRO-2070 tolerate any numbers in GenericDatumWriter while writing primitives in java

This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 2c238747755a19fe6acce107b6fb1ce7d1984563
Author: ravowlga123 <ra...@gmail.com>
AuthorDate: Fri Dec 6 15:10:17 2019 +0100

    AVRO-2070 tolerate any numbers in GenericDatumWriter while writing primitives in java
---
 .../src/main/java/org/apache/avro/generic/GenericDatumWriter.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
index 0515fd4..d3a812b 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
@@ -86,7 +86,7 @@ public class GenericDatumWriter<D> implements DatumWriter<D> {
   /**
    * Convert a high level representation of a logical type (such as a BigDecimal)
    * to the its underlying representation object (such as a ByteBuffer).
-   * 
+   *
    * @throws IllegalArgumentException if a null schema or logicalType is passed in
    *                                  while datum and conversion are not null.
    *                                  Please be noticed that the exception type
@@ -156,13 +156,13 @@ public class GenericDatumWriter<D> implements DatumWriter<D> {
         out.writeInt(((Number) datum).intValue());
         break;
       case LONG:
-        out.writeLong((Long) datum);
+        out.writeLong(((Number) datum).longValue());
         break;
       case FLOAT:
-        out.writeFloat((Float) datum);
+        out.writeFloat(((Number) datum).floatValue());
         break;
       case DOUBLE:
-        out.writeDouble((Double) datum);
+        out.writeDouble(((Number) datum).doubleValue());
         break;
       case BOOLEAN:
         out.writeBoolean((Boolean) datum);