kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject [kafka] branch 0.11.0 updated: KAFKA-7058: Comparing schema default values using Objects#deepEquals()
Date Sun, 17 Jun 2018 06:12:57 GMT
This is an automated email from the ASF dual-hosted git repository.

ewencp pushed a commit to branch 0.11.0
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/0.11.0 by this push:
     new 95fbb2e  KAFKA-7058: Comparing schema default values using Objects#deepEquals()
95fbb2e is described below

commit 95fbb2e03f4fe79737c71632e0ef2dfdcfb85a69
Author: Gunnar Morling <gunnar.morling@googlemail.com>
AuthorDate: Sat Jun 16 23:04:31 2018 -0700

    KAFKA-7058: Comparing schema default values using Objects#deepEquals()
    
    https://issues.apache.org/jira/browse/KAFKA-7058
    * Summary of testing strategy: Added new unit test
    
    Author: Gunnar Morling <gunnar.morling@googlemail.com>
    
    Reviewers: Randall Hauch <rhauch@gmail.com>, Ewen Cheslack-Postava <ewen@confluent.io>
    
    Closes #5225 from gunnarmorling/KAFKA-7058
    
    (cherry picked from commit be846d833caade74f1d0536ecf9d540855cde758)
    Signed-off-by: Ewen Cheslack-Postava <me@ewencp.org>
---
 .../main/java/org/apache/kafka/connect/data/ConnectSchema.java |  2 +-
 .../java/org/apache/kafka/connect/data/ConnectSchemaTest.java  | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

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 651b2ee..30917fc 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
@@ -284,7 +284,7 @@ public class ConnectSchema implements Schema {
         ConnectSchema schema = (ConnectSchema) o;
         return Objects.equals(optional, schema.optional) &&
                 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 339ef23..048784e 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
@@ -269,6 +269,16 @@ public class ConnectSchemaTest {
     }
 
     @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
         ConnectSchema s1 = new ConnectSchema(Schema.Type.MAP, false, null, null, null, null,
null, null, SchemaBuilder.int8().build(), SchemaBuilder.int16().build());

-- 
To stop receiving notification emails like this one, please contact
ewencp@apache.org.

Mime
View raw message