Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1569

ReflectData.AllowNull fails with polymorphism

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.6
    • None
    • java
    • None

    Description

      UnresolvedUnionException is thrown if the following structure is serialized with ReflectData.AllowNull
      (Plain ReflectData works fine)

      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());
      
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sachingoyal Sachin Goyal
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: