You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Thiruvalluvan M. G. (JIRA)" <ji...@apache.org> on 2018/12/30 05:33:00 UTC

[jira] [Updated] (AVRO-1570) ReflectData.AllowNull fails with polymorphism and @Union annotation

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

Thiruvalluvan M. G. updated AVRO-1570:
--------------------------------------
    Component/s: java

> ReflectData.AllowNull fails with polymorphism and @Union annotation
> -------------------------------------------------------------------
>
>                 Key: AVRO-1570
>                 URL: https://issues.apache.org/jira/browse/AVRO-1570
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.6
>            Reporter: Sachin Goyal
>            Priority: Major
>
> Nested union exception is thrown if the following structure is serialized with ReflectData.AllowNull
> (Plain ReflectData works fine)
> {code}
> @Union({Derived.class})
> class Base 
> {
>    Integer a = 5;
> }
> class Derived extends Base
> {
>     String b = "Foo";
> }
> class PolymorphicDO
> {
>    Base obj = new Derived();
> }
> // Serialization code:
> ReflectData rdata = ReflectData.AllowNull.get();
> Schema schema = rdata.getSchema(PolymorphicDO.class);
> ReflectDatumWriter<T> datumWriter = new ReflectDatumWriter (PolymorphicDO.class, rdata);
> DataFileWriter<T> fileWriter = new DataFileWriter<T> (datumWriter);
> fileWriter.create(schema, new ByteArrayOutputStream());
> fileWriter.append(new PolymorphicDO());
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)