[
https://issues.apache.org/jira/browse/AVRO-1810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15190041#comment-15190041
]
Ryon Day commented on AVRO-1810:
--------------------------------
Thanks for the quick response!
Yes, doing a {{gradle build}} at the top level (assuming you use Gradle...)
should result in the domain objects being built and output in the
{{build/generated-main-avro-java}} directory.
With respect to {{UTF8}} vs {{String}}, I regret my incendiary language there;
it is just one of those things we have had to work around after a lot of
{{ClassCastException}}s.
We generate our domain objects using {{String}} and therefore interoperability
with teams who don't do so is terrible (I am working on defining additional
test cases that show that {{GenericData.deepCopy()}} and
{{SpecificData.deepCopy()}} do not work in many cases, ending up something like
this:
{code}
java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to
java.lang.String
at our.package.domainObject.put(domainObject.java:151)
at org.apache.avro.generic.GenericData.setField(GenericData.java:573)
at org.apache.avro.generic.GenericData.setField(GenericData.java:590)
at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:972)
{code}
> GenericDatumWriter broken with Enum
> -----------------------------------
>
> Key: AVRO-1810
> URL: https://issues.apache.org/jira/browse/AVRO-1810
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.8.0
> Reporter: Ryon Day
> Priority: Blocker
>
> {panel:title=Description|titleBGColor=#3FA|bgColor=#DDD}
> Using the GenericDatumWriter with either Generic OR SpecificRecord will break
> if an Enum is present.
> {panel}
> {panel:title=Steps To Reproduce|titleBGColor=#8DB|bgColor=#DDD}
> I have been tracking Avro decoding oddities for a while.
> The tests for this issue can be found
> [here|https://github.com/ryonday/avroDecodingHelp/blob/master/src/test/java/com/ryonday/test/Avro180EnumFail.java]
> {panel}
> {panel:title=Notes|titleBGColor=#3AF|bgColor=#DDD}
> Due to the debacle that is the Avro "UTF8" object, we have been avoiding it
> by using the following scheme:
> * Write incoming records to a byte array using the GenericDatumWriter
> * Read back the byte array to our compiled Java domain objects using a
> SpecificDatumWriter
> This worked great with Avro 1.7.7, and this is a binary-incompatable breaking
> change with 1.8.0.
> This would appear to be caused by an addition in the
> {{GenericDatumWriter:163-164}}:
> {code}
> if (!data.isEnum(datum))
> throw new AvroTypeException("Not an enum: "+datum);
> {code}
> {panel}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)