[ 
https://issues.apache.org/jira/browse/KAFKA-7058?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16515005#comment-16515005
 ] 

ASF GitHub Bot commented on KAFKA-7058:
---------------------------------------

ewencp closed pull request #5225: KAFKA-7058 [Connect] Comparing schema default 
values using Objects#deepEquals()
URL: https://github.com/apache/kafka/pull/5225
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java 
b/connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java
index ff8271635f3..f1a05bb19a6 100644
--- a/connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java
+++ b/connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java
@@ -291,7 +291,7 @@ public boolean equals(Object o) {
                 Objects.equals(name, schema.name) &&
                 Objects.equals(doc, schema.doc) &&
                 Objects.equals(type, schema.type) &&
-                Objects.equals(defaultValue, schema.defaultValue) &&
+                Objects.deepEquals(defaultValue, schema.defaultValue) &&
                 Objects.equals(fields, schema.fields) &&
                 Objects.equals(keySchema, schema.keySchema) &&
                 Objects.equals(valueSchema, schema.valueSchema) &&
diff --git 
a/connect/api/src/test/java/org/apache/kafka/connect/data/ConnectSchemaTest.java
 
b/connect/api/src/test/java/org/apache/kafka/connect/data/ConnectSchemaTest.java
index 339ef23ca54..048784e3335 100644
--- 
a/connect/api/src/test/java/org/apache/kafka/connect/data/ConnectSchemaTest.java
+++ 
b/connect/api/src/test/java/org/apache/kafka/connect/data/ConnectSchemaTest.java
@@ -268,6 +268,16 @@ public void testArrayEquality() {
         assertNotEquals(s1, differentValueSchema);
     }
 
+    @Test
+    public void testArrayDefaultValueEquality() {
+        ConnectSchema s1 = new ConnectSchema(Schema.Type.ARRAY, false, new 
String[] {"a", "b"}, null, null, null, null, null, null, 
SchemaBuilder.int8().build());
+        ConnectSchema s2 = new ConnectSchema(Schema.Type.ARRAY, false, new 
String[] {"a", "b"}, null, null, null, null, null, null, 
SchemaBuilder.int8().build());
+        ConnectSchema differentValueSchema = new 
ConnectSchema(Schema.Type.ARRAY, false, new String[] {"b", "c"}, null, null, 
null, null, null, null, SchemaBuilder.int8().build());
+
+        assertEquals(s1, s2);
+        assertNotEquals(s1, differentValueSchema);
+    }
+
     @Test
     public void testMapEquality() {
         // Same as testArrayEquality, but for both key and value schemas


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> ConnectSchema#equals() broken for array-typed default values
> ------------------------------------------------------------
>
>                 Key: KAFKA-7058
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7058
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>    Affects Versions: 1.0.0, 1.1.0
>            Reporter: Gunnar Morling
>            Priority: Major
>
> {{ConnectSchema#equals()}} calls {{Objects#equals()}} for the schemas' 
> default values, but this doesn't work correctly if the default values in fact 
> are arrays. In this case, always {{false}} will be returned, also if the 
> default value arrays actually are the same.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to