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

GenericDatumReader throws an error when it tries to cache a resolver

    XMLWordPrintableJSON

Details

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

    Description

      When the GenericDatumReader tries to create a resolver with the reader schema which contains a union where the default value is incompatible with the first field. It throws an error. As the resolvers are cached, when the resolver is not created, it is not pushed in the cache which results in an attempt to create a resolver whenever it tries to read a message. A possible fix is to not have a lazy initialization of the resolver but to have it at time of the creation of GenericDatumReader and handle the error at start. This ensures that the datumReader fails fast and will not try to create the resolver everytime it tries to read a message. An example of the reader schema

      String readerSchemaDescription = " { \n"
      + " \"name\": \"User\", \n"
      + " \"type\": \"record\",\n" + " \"fields\": [\n"
      + "

      {\"name\": \"id\", \"type\": \"int\"}

      ,\n"
      + "

      {\"name\": \"temp\", \"type\": [\"null\",\"string\"], \"default\":\"foo\"}

      ,\n"
      + "

      {\"name\": \"name\", \"type\": \"string\", \"default\":\"avro\"}

      ]\n" + "}";

      Attachments

        Activity

          People

            Unassigned Unassigned
            rnair Ruma Nair
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified