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

NPE validating schema with enum types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.10.2
    • 1.11.0
    • java
    • None

    Description

      I ran into a bug with schema validation code that throws unexpected NullPointerException when validating a schema with enum type. The bug is present in latest version of Avro Java API.

      Schema to replicate issue: 

      { "type": "enum", "name": "Suit", "symbols" : [null] }

      Replication Steps:

      1. Validate the above schema using Java API.
      2. I used avro-cli for testing but was also able to replicate with API.
      3. java -jar avro-cli-0.2.7.jar normalize -s ~/tmp/schema.txt

      Exception:

      java.lang.NullPointerException: nullat org.apache.avro.Schema.validateName(Schema.java:1557) ~[avro-1.10.2.jar:1.10.2]
      at org.apache.avro.Schema.access$400(Schema.java:91) ~[avro-1.10.2.jar:1.10.2]
      at org.apache.avro.Schema$EnumSchema.<init>(Schema.java:1035) ~[avro-1.10.2.jar:1.10.2]
      at org.apache.avro.Schema.parse(Schema.java:1709) ~[avro-1.10.2.jar:1.10.2]
      at org.apache.avro.Schema.parse(Schema.java:1673) ~[avro-1.10.2.jar:1.10.2]
      at org.apache.avro.Schema$Parser.parse(Schema.java:1430) ~[avro-1.10.2.jar:1.10.2]
      at org.apache.avro.Schema$Parser.parse(Schema.java:1418) ~[avro-1.10.2.jar:1.10.2]

       

      As seen in the code, there is no null check on symbol which is causing this.

      Attachments

        Activity

          People

            fokko Fokko Driesprong
            blacktooth Ravindranath Kakarla
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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