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

Union of enum and null can result in NPE on validate if null is not first

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.6
    • Fix Version/s: 1.7.8, 1.8.0
    • Component/s: java
    • Labels:
      None

      Description

      The ENUM case in validate is missing a null check for datum:

          case ENUM:
            return schema.getEnumSymbols().contains(datum.toString());
      

      This leads to a surprising error where a NPE is thrown for a union of enum and null when the enum is first in the union. If null is first it works. The fix is a simple. I'm creating a patch that adds the fix and a unit test for this case.

        Attachments

        1. AVRO-1544.patch
          2 kB
          Matthew Hayes
        2. AVRO-1544-v2.patch
          2 kB
          Matthew Hayes

          Activity

            People

            • Assignee:
              matterhayes Matthew Hayes
              Reporter:
              matterhayes Matthew Hayes
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: