Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-9192

NullPointerException if field in schema not present in value

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.2.3, 2.5.0, 2.3.2, 2.4.1
    • Component/s: KafkaConnect
    • Labels:
      None

      Description

      Given a message:

      {
         "schema":{
            "type":"struct",
            "fields":[
               {
                  "type":"string",
                  "optional":true,
                  "field":"abc"
               }
            ],
            "optional":false,
            "name":"foobar"
         },
         "payload":{
         }
      }
      

      I would expect, given the field is optional, for the JsonConverter to still process this value.

      What happens is I get a null pointer exception, the stacktrace points to this line: https://github.com/apache/kafka/blob/2.1/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java#L701 called by https://github.com/apache/kafka/blob/2.1/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java#L181

      Issue seems to be that we need to check and see if the jsonValue is null before checking if the jsonValue has a null value.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                mt3593 Mark Tinsley
                Reviewer:
                Randall Hauch
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: