Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2212

GenericData.deepCopyRaw not working with java.lang.BigDecimal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.8.2
    • 1.8.2
    • java
    • None

    Description

      With an AVDL of:

        @namespace("com.foo")
        record SomethingWithDec {
          decimal(8,2) dec;
        }
      

      and the Scala/Java code of:

      object Foo extends App {
        import com.foo.SomethingWithDec
        val x =  SomethingWithDec.newBuilder().setDec(new java.math.BigDecimal("1234"))
        val y = SomethingWithDec.newBuilder(x).build()
      }
      

      I get the exception:

      Exception in thread "main" java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.nio.ByteBuffer
      	at org.apache.avro.generic.GenericData.deepCopyRaw(GenericData.java:1089)
      	at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1065)
      	at com.foo.SomethingWithDec$Builder.<init>(SomethingWithDec.java:167)
      	at com.foo.SomethingWithDec$Builder.<init>(SomethingWithDec.java:150)
      	at com.foo.SomethingWithDec.newBuilder(SomethingWithDec.java:135)
      

      I have attached the generated Java class for SomethingWithDec.

      This seems related to AVRO-1895, but I believe that was meant to have been fixed in 1.8.2.

      Attachments

        1. SomethingWithDec.java
          8 kB
          Sean Policarpio

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kdrakon Sean Policarpio
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: