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

ReflectDatumReader doesn't work with SpecificRecords containing an array of values

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.7.0
    • Component/s: java
    • Labels:
      None

      Description

      When a ReflectDatumReader is used to read implementations of SpecificRecord, it fails if the SpecificRecord includes an (avro) array. This appears to be due to the fact that the newArray method in ReflectDatumReader works differently (based on a reflection-based schema) than the newArray method in GenericDatumReader (which is the base class of the DatumReaders).

      The included patch simply removes the delegation to SpecificData for the creation of a schema in the case of a SpecificRecord. My assumption is that the delegation to SpecificData is for performance reasons.

      The rationale in removing the delegation to SpecificData is that a) it doesn't work completely correctly, as demonstrated, and b) if a user is using ReflectDatumReader (instead of SpecificDatumReader) to read SpecificRecords, there may be other underlying reasons that reflection is specifically chosen, and so this intention should not be undermined by the delegation to SpecificData.

        Attachments

        1. AVRO-1046.patch
          18 kB
          Doug Cutting
        2. AVRO-1046.patch
          16 kB
          Gabriel Reid

          Activity

            People

            • Assignee:
              cutting Doug Cutting
              Reporter:
              gabriel.reid Gabriel Reid
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: