[ 
https://issues.apache.org/jira/browse/AVRO-1020?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

James Baldassari updated AVRO-1020:
-----------------------------------

    Attachment: AVRO-1020.bug.patch

Here's a patch that exercises the bug.  After applying this patch, 
TestSpecificRecordBuilder#testSpecificBuilder() fails.
                
> Builder API fails to substitute default values for enum types
> -------------------------------------------------------------
>
>                 Key: AVRO-1020
>                 URL: https://issues.apache.org/jira/browse/AVRO-1020
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.6.1
>            Reporter: James Baldassari
>         Attachments: AVRO-1020.bug.patch
>
>
> If a schema has an enum type with a default value, and the Builder API is 
> used to automatically substitute the default value on build(), a 
> ClassCastException is thrown.  The reason is that the default value resolves 
> to a GenericData.EnumSymbol.  The specific builder then attempts to cast this 
> value to the corresponding Java enum type, which fails.  Here is an example 
> stack trace:
> {noformat}
> org.apache.avro.AvroRuntimeException: java.lang.ClassCastException: 
> org.apache.avro.generic.GenericData$EnumSymbol cannot be cast to 
> org.apache.avro.ipc.specific.PrivacyType
>       at org.apache.avro.ipc.specific.Person$Builder.build(Person.java:410)
>       at 
> org.apache.avro.specific.TestSpecificRecordBuilder.testSpecificBuilder(TestSpecificRecordBuilder.java:51)
> Caused by: java.lang.ClassCastException: 
> org.apache.avro.generic.GenericData$EnumSymbol cannot be cast to 
> org.apache.avro.ipc.specific.PrivacyType
>       at org.apache.avro.ipc.specific.Person$Builder.build(Person.java:407)
>       ... 24 more
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to