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

Connect Struct schemas built using SchemaBuilder with no fields cause NPE in Struct constructor

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.10.0.1
    • Fix Version/s: 0.10.1.0
    • Component/s: KafkaConnect
    • Labels:
      None

      Description

      Avro records can legitimately have 0 fields (though arguable how useful that is).

      When using the Confluent Schema Registry's AvroConverter with such a schema,

      java.lang.NullPointerException
      	at org.apache.kafka.connect.data.Struct.<init>(Struct.java:56)
      	at io.confluent.connect.avro.AvroData.toConnectData(AvroData.java:980)
      	at io.confluent.connect.avro.AvroData.toConnectData(AvroData.java:782)
      	at io.confluent.connect.avro.AvroConverter.toConnectData(AvroConverter.java:103)
      	at org.apache.kafka.connect.runtime.WorkerSinkTask.convertMessages(WorkerSinkTask.java:358)
      	at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:227)
      	at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:171)
      	at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:143)
      	at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:140)
      	at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:175)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      

      This is because it is using the SchemaBuilder to create the Struct schema, which provides a field(..) builder for each field. If there are no fields, the list stays as null.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shikhar Shikhar Bhushan
                Reporter:
                shikhar Shikhar Bhushan
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: