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

Sachin Goyal commented on AVRO-1569:
------------------------------------

I think we probably need both the fixes.

The fix in this ticket is required when the user really does not care about 
serializing exact derived objects.
Maybe its third party code and user cannot put AvroIgnore on so many 
polymorphic objects in that code.
But the user just wants to serialize such objects without being bothered by the 
complexity of AVRO-1568.

Also the current fix will make it consistent with ReflectData without AllowNull.
AVRO-1568 is for polymorphic objects whose exact serialization is really 
desired and the user is ready to write some extra code to make sure they do so.

> ReflectData.AllowNull fails with polymorphism
> ---------------------------------------------
>
>                 Key: AVRO-1569
>                 URL: https://issues.apache.org/jira/browse/AVRO-1569
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.7.6
>            Reporter: Sachin Goyal
>
> UnresolvedUnionException is thrown if the following structure is serialized 
> with ReflectData.AllowNull
> (Plain ReflectData works fine)
> {code}
> 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
(v6.3.4#6332)

Reply via email to