Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-3949

NullPointerException from GrokReader

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.2.0
    • 1.3.0
    • None
    • None

    Description

      When creating a GrokReader, I specified an expression of:

      %{SYSLOGBASE}%{GREEDYDATA:message}

      And I left the default schema strategy of "use fields from grok expression".

      This resulted in an NPE:

      java.lang.NullPointerException: null
      	at java.util.Objects.requireNonNull(Objects.java:203)
      	at org.apache.nifi.serialization.record.RecordField.<init>(RecordField.java:50)
      	at org.apache.nifi.serialization.record.RecordField.<init>(RecordField.java:33)
      	at org.apache.nifi.grok.GrokReader.createRecordSchema(GrokReader.java:150)
      	at org.apache.nifi.grok.GrokReader.preCompile(GrokReader.java:136)
      

      This appears to be because I didn't specify a name for SYSLOGBASE, since I was expecting it to see what SYSLOGBASE expands to and then use and named fields under that. If we don't want to support that expansion, then we should at least validate that all parts of the Grok expression have a name.

      Next I changed to using a schema defined in an AvroSchemaRegistry and referencing it by name, but I still got the above exception because the preCompile method always attempts to create a RecordSchema from the GrokExpression, even if you selected a different strategy.

      Attachments

        Issue Links

          Activity

            People

              markap14 Mark Payne
              bbende Bryan Bende
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: