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

Support parameterized types in Avro

Add voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.6, 1.7.7, 1.8.1
    • None
    • java
    • None

    Description

      The below code cannot be serialized by Avro.

      class Leaf <P, Q> {
        P p;
        Q q;
      }
      
      class Root {
        Middle1 m1;
        Middle2 m2;
        Middle3<Integer> m3;
      }
      
      class Middle1 {
        Leaf <Integer, Long> foo;
      }
      
      class Middle2 {
        Leaf <String, String> foo;
      }
      
      class Middle3 <P> {
        Leaf <P, P> foo;
      }
      
      

      This is because when generating the schema, only the current class is used to generate the schema.
      The parent class' context is missing in ReflectData#createSchema() functions where the actual type-information is actually present.

      Please see the attached test too for a simpler case.

      Attachments

        1. ParameterizedTypesTest.java
          1.0 kB
          Sachin Goyal

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            sachingoyal Sachin Goyal

            Dates

              Created:
              Updated:

              Slack

                Issue deployment