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

Kafka Connect's Struct objects rehydrated with JSON converter are not equal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 0.10.0.0
    • None
    • connect
    • None

    Description

      The equals(...) method on org.apache.kafka.connect.data.Struct currently uses Arrays.equals(value,o.value) to compare the array of field values to that of another. However, this only works when the elements in those arrays (e.g., the field values) are primitives or objects, but fails to work when they are arrays such as byte[].

      Interestingly, the StructTest unit test populates all fields of type Schema.BYTES_SCHEMA using ByteBuffer object, which means the current logic works fine. However, the JSON converter rehydrates the Struct objects using byte[], whereas the Avro converter rehydrates using ByteBuffer. This means that when a Struct containing a Schema.BYTES_SCHEMA or Schema.OPTIONAL_BYTES_SCHEMA field is serialized and then deserialized with the JSON converter, the rehydrated object will not be deemed "equal" to the original.

      Attachments

        Issue Links

          Activity

            People

              ewencp Ewen Cheslack-Postava
              rhauch Randall Hauch
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: