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

IdlReader in Avro 1.12.0 fails with NPE on complex types with empty default value

    XMLWordPrintableJSON

Details

    Description

      Given this avdl (TestProtocol.avdl):

      protocol TestProtocol {
          record Test {
              map<string> myMap = {};
          }
      }
      

      With Avro 1.12.0 'IdlReader' fails with a NullPointerException:

      $ java -jar avro-tools-1.12.0.jar idl ./TestProtocol.avdl
      Exception in thread "main" org.apache.avro.SchemaParseException: java.lang.NullPointerException: Cannot invoke "org.antlr.v4.runtime.Token.getText()" because "stringToken" is null
      	at org.apache.avro.idl.IdlReader.parse(IdlReader.java:224)
      	at org.apache.avro.idl.IdlReader.parse(IdlReader.java:187)
      	at org.apache.avro.idl.IdlReader.parse(IdlReader.java:172)
      	at org.apache.avro.tool.IdlTool.run(IdlTool.java:70)
      	at org.apache.avro.tool.Main.run(Main.java:67)
      	at org.apache.avro.tool.Main.main(Main.java:56)
      Caused by: java.lang.NullPointerException: Cannot invoke "org.antlr.v4.runtime.Token.getText()" because "stringToken" is null
      	at org.apache.avro.idl.IdlReader$IdlParserListener.getString(IdlReader.java:975)
      	at org.apache.avro.idl.IdlReader$IdlParserListener.exitJsonPair(IdlReader.java:926)
      	at org.apache.avro.idl.IdlParser$JsonPairContext.exitRule(IdlParser.java:2558)
      	at org.antlr.v4.runtime.Parser.triggerExitRuleEvent(Parser.java:410)
      	at org.antlr.v4.runtime.Parser.exitRule(Parser.java:642)
      	at org.apache.avro.idl.IdlParser.idlFile(IdlParser.java:289)
      	at org.apache.avro.idl.IdlReader.parse(IdlReader.java:220)
      	... 5 more
      

      With Avro 1.11.3

      $ java -jar avro-tools-1.11.3.jar idl ./TestProtocol.avdl
      {
        "protocol" : "TestProtocol",
        "types" : [ {
          "type" : "record",
          "name" : "Test",
          "fields" : [ {
            "name" : "myMap",
            "type" : {
              "type" : "map",
              "values" : "string"
            },
            "default" : { }
          } ]
        } ],
        "messages" : { }
      }
      

      Attachments

        Issue Links

          Activity

            People

              opwvhk Oscar Westra van Holthe - Kind
              rroesch Raphael Rösch
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m