avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-997) Generic API should require GenericEnumSymbol when writing Avro Enums
Date Fri, 03 Oct 2014 21:37:34 GMT

    [ https://issues.apache.org/jira/browse/AVRO-997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14158557#comment-14158557
] 

Hudson commented on AVRO-997:
-----------------------------

SUCCESS: Integrated in AvroJava #484 (See [https://builds.apache.org/job/AvroJava/484/])
AVRO-997. Java: For enum values, no longer sometimes permit any Object whose toString() names
an enum symbol, but rather always require use of distinct enum types.  Contributed by Sean
Busbey. (cutting: rev 1629315)
* /avro/trunk/CHANGES.txt
* /avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
* /avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
* /avro/trunk/lang/java/avro/src/test/java/org/apache/avro/TestSchemaCompatibility.java
* /avro/trunk/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericData.java
* /avro/trunk/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericDatumWriter.java
* /avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestCompare.java


> Generic API should require GenericEnumSymbol when writing Avro Enums
> --------------------------------------------------------------------
>
>                 Key: AVRO-997
>                 URL: https://issues.apache.org/jira/browse/AVRO-997
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.5.1
>            Reporter: Aaron Kimball
>            Assignee: Sean Busbey
>             Fix For: 1.8.0
>
>         Attachments: AVRO-997.patch, AVRO-997.patch, AVRO-997.patch, AVRO-997.permissive-generic-api.patch
>
>
> I have a schema like:
> {code}
> [
> {
>   "type": "enum",
>   "name": "Gender",
>   "symbols": ["M", "F"]
> },
> {
>   "type" : "record",
>   "name" : "Foo",
>   "fields" : [
>     { "type" : ["Gender", "null"], "name" : "gender" },
>     ...
>   ]
> }
> ]
> {code}
> I build a record like {{Foo foo = new Foo(); foo.gender = Gender.M;}}
> When I go to serialize this, I get:
> {code}Not in union [{"type":"enum","name":"Gender","symbols":["M","F"]},"null"]: M
> 	at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:482)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:70)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:104)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:57)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message