You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2020/06/08 13:00:10 UTC
[jira] [Commented] (AVRO-2139) Add Test for Decimal @java-class
Annotated Generated Classes
[ https://issues.apache.org/jira/browse/AVRO-2139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17128280#comment-17128280 ]
ASF subversion and git services commented on AVRO-2139:
-------------------------------------------------------
Commit 51d0fe8451bc15e3274ba2f0c5ae0260fcfcb78b in avro's branch refs/heads/master from belugabehr
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=51d0fe8 ]
AVRO-2139: Add Test for Decimal @java-class Annotated Generated Classes (#909)
> Add Test for Decimal @java-class Annotated Generated Classes
> ------------------------------------------------------------
>
> Key: AVRO-2139
> URL: https://issues.apache.org/jira/browse/AVRO-2139
> Project: Apache Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.8.2
> Reporter: Auke van Leeuwen
> Assignee: David Mollitor
> Priority: Minor
> Fix For: 1.10.0
>
>
> Description:
> When I'm using a schema with an {{@java-class}}, I can't seem to be using the 'copy' builder.
> I think a piece of code says more than a thousands words:
> {{.avdl}} snippet:
> {noformat}
> ...
> record Money {
> Currency currency;
> @java-class("java.math.BigDecimal")
> string amount;
> }
> ...
> {noformat}
> Test:
> {noformat}
> @Test
> void test_copy_builder() {
> Money original = Money.newBuilder()
> .setAmount(BigDecimal.TEN)
> .setCurrency(Currency.EUR)
> .build();
> Money duplicate = Money.newBuilder(original).build();
> assertThat(duplicate, is(equalTo(original)));
> }
> {noformat}
> Result:
> {noformat}
> java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to java.math.BigDecimal
> at avro.moneyou.midlayer.common.financial.Money$Builder.<init>(Money.java:193)
> at avro.moneyou.midlayer.common.financial.Money$Builder.<init>(Money.java:155)
> at avro.moneyou.midlayer.common.financial.Money.newBuilder(Money.java:149)
> at avro.moneyou.midlayer.common.financial.MoneyTest.test_copy_builder(MoneyTest.java:20)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:389)
> at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
> at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:167)
> at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
> at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:163)
> ...
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)