You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Tobias Gies (JIRA)" <ji...@apache.org> on 2017/12/04 16:55:00 UTC

[jira] [Updated] (KAFKA-6308) Connect: Struct#equals should use Arrays#deepEquals

     [ https://issues.apache.org/jira/browse/KAFKA-6308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tobias Gies updated KAFKA-6308:
-------------------------------
    Description: 
At the moment, {{org.apache.kafka.connect.data.Struct#equals}} checks two things, after ensuring the incoming {{Object o}} is indeed of the correct type:

* Whether the schemas of {{this}} and {{o}} are equal, via {{Objects.equals}}
* Whether the values of {{this}} and {{o}} are qual, via {{Arrays.equals}}.

The latter check is wrong. {{Arrays.equals}} is meant for one-dimensional arrays of any kind, and thus simply checks the {{equals}} methods of two corresponding elements. However, elements of the {{values}} array may themselves be arrays, for example if a field has the schema {{Schema.OPTIONAL_BYTES_SCHEMA}}.

Given that, the correct method to use to compare the {{values}} arrays of two {{Struct}} instances is {{Arrays#deepEquals}}.

  was:
At the moment, {{org.apache.kafka.connect.data.Struct#equals}} checks two things, after ensuring the incoming {{Object o}} is indeed of the correct type:

* Whether the schemas of {{this}} and {{o}} are equal, via {{Objects.equals}}
* Whether the values of {{this}} and {{o}} are qual, via {{Arrays.equals}}.

The latter check is wrong. {{Arrays.equals}} is meant for one-dimensional arrays of any kind, and thus simply checks the {{equals}} methods of two corresponding elements. However, elements of the {{values}} array may themselves be arrays, for example if a field has the schema {{Schema.OPTIONAL_BYTES_SCHEMA}}.

Given that, the correct method to use to compare the {{values}} arrays of two {{Struct}} instances is {{Arrays.deepEquals}}.


> Connect: Struct#equals should use Arrays#deepEquals
> ---------------------------------------------------
>
>                 Key: KAFKA-6308
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6308
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>    Affects Versions: 1.0.0
>            Reporter: Tobias Gies
>              Labels: easyfix, newbie
>
> At the moment, {{org.apache.kafka.connect.data.Struct#equals}} checks two things, after ensuring the incoming {{Object o}} is indeed of the correct type:
> * Whether the schemas of {{this}} and {{o}} are equal, via {{Objects.equals}}
> * Whether the values of {{this}} and {{o}} are qual, via {{Arrays.equals}}.
> The latter check is wrong. {{Arrays.equals}} is meant for one-dimensional arrays of any kind, and thus simply checks the {{equals}} methods of two corresponding elements. However, elements of the {{values}} array may themselves be arrays, for example if a field has the schema {{Schema.OPTIONAL_BYTES_SCHEMA}}.
> Given that, the correct method to use to compare the {{values}} arrays of two {{Struct}} instances is {{Arrays#deepEquals}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)