You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Sean Policarpio (JIRA)" <ji...@apache.org> on 2018/08/20 00:24:00 UTC
[jira] [Commented] (AVRO-2212) GenericData.deepCopyRaw not working
with java.lang.BigDecimal
[ https://issues.apache.org/jira/browse/AVRO-2212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16585307#comment-16585307 ]
Sean Policarpio commented on AVRO-2212:
---------------------------------------
Was also able to reproduce in Java:
{code:Java}
class Scratch {
public static void main(String[] args) {
SomethingWithDec x = SomethingWithDec.newBuilder().setDec(new BigDecimal("1234")).build();
SomethingWithDec y = SomethingWithDec.newBuilder(x).build();
}
}
{code}
{noformat}
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:179)
at com.foo.SomethingWithDec$Builder.<init>(SomethingWithDec.java:150)
at com.foo.SomethingWithDec.newBuilder(SomethingWithDec.java:144)
{noformat}
> GenericData.deepCopyRaw not working with java.lang.BigDecimal
> -------------------------------------------------------------
>
> Key: AVRO-2212
> URL: https://issues.apache.org/jira/browse/AVRO-2212
> Project: Avro
> Issue Type: Bug
> Affects Versions: 1.8.2
> Reporter: Sean Policarpio
> Priority: Critical
> Attachments: SomethingWithDec.java
>
>
> With an AVDL of:
> {code:java}
> @namespace("com.foo")
> record SomethingWithDec {
> decimal(8,2) dec;
> }
> {code}
> and the Scala/Java code of:
> {code}
> object Foo extends App {
> import com.foo.SomethingWithDec
> val x = SomethingWithDec.newBuilder().setDec(new java.math.BigDecimal("1234"))
> val y = SomethingWithDec.newBuilder(x).build()
> }
> {code}
> I get the exception:
> {noformat}
> 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)
> {noformat}
> 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.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)