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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.6
    • 1.8.0, 1.9.0
    • java
    • 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-v2.patch
          2 kB
          Matthew Hayes
        2. AVRO-1544.patch
          2 kB
          Matthew Hayes

        Activity

          People

            mhayes Matthew Hayes
            mhayes Matthew Hayes
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: