Avro
  1. Avro
  2. AVRO-1544

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.6
    • Fix Version/s: 1.7.8
    • 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.

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

        Activity

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development