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

NullPointerException when returning null from a custom WriteModelStrategy

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.5.1
    • Affects Version/s: 1.5.0
    • Component/s: Sink

      Returning null from a custom WriteModelStrategy (as documented in https://docs.mongodb.com/kafka-connector/current/kafka-sink-postprocessors/#:~:text=Return%20null%20to%20indicate%20no%20op) throws a NullPointerException when trying to wrap the returned value in a java.util.Optional.

       

      The fix seems trivial: Use Optional.ofNullable(value) instead of Optional.of(value)

      https://github.com/mongodb/mongo-kafka/blob/122cfbe5e7fb7b1949e7f2d1298e1e0c540e6a5d/src/main/java/com/mongodb/kafka/connect/sink/MongoProcessedSinkRecordData.java#L91

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            diegodiez.ddr@gmail.com Diego Díez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: