You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2021/02/12 16:49:50 UTC

[kafka] branch 2.7 updated: KAFKA-12321 the comparison function for uuid type should be 'equals' rather than '==' (#10098)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/2.7 by this push:
     new 35f6d74  KAFKA-12321 the comparison function for uuid type should be 'equals' rather than '==' (#10098)
35f6d74 is described below

commit 35f6d749ce25f4096381c5cd27b6e7724b1eba32
Author: Chia-Ping Tsai <ch...@gmail.com>
AuthorDate: Sat Feb 13 00:43:14 2021 +0800

    KAFKA-12321 the comparison function for uuid type should be 'equals' rather than '==' (#10098)
    
    Reviewers: Ismael Juma <is...@juma.me.uk>
---
 .../test/java/org/apache/kafka/common/message/MessageTest.java | 10 ++++++++++
 .../src/main/java/org/apache/kafka/message/FieldSpec.java      |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/clients/src/test/java/org/apache/kafka/common/message/MessageTest.java b/clients/src/test/java/org/apache/kafka/common/message/MessageTest.java
index 9672bf4..94e6bc2 100644
--- a/clients/src/test/java/org/apache/kafka/common/message/MessageTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/message/MessageTest.java
@@ -737,6 +737,16 @@ public final class MessageTest {
     }
 
     @Test
+    public void defaultValueShouldBeWritable() {
+        for (short version = SimpleExampleMessageData.LOWEST_SUPPORTED_VERSION; version <= SimpleExampleMessageData.HIGHEST_SUPPORTED_VERSION; ++version) {
+            ObjectSerializationCache cache = new ObjectSerializationCache();
+            Message message = new SimpleExampleMessageData();
+            ByteBuffer buf = ByteBuffer.allocate(message.size(cache, version));
+            message.write(new ByteBufferAccessor(buf), cache, version);
+        }
+    }
+
+    @Test
     public void testSimpleMessage() throws Exception {
         final SimpleExampleMessageData message = new SimpleExampleMessageData();
         message.setMyStruct(new SimpleExampleMessageData.MyStruct().setStructId(25).setArrayInStruct(
diff --git a/generator/src/main/java/org/apache/kafka/message/FieldSpec.java b/generator/src/main/java/org/apache/kafka/message/FieldSpec.java
index 3bdbe57..b399335 100644
--- a/generator/src/main/java/org/apache/kafka/message/FieldSpec.java
+++ b/generator/src/main/java/org/apache/kafka/message/FieldSpec.java
@@ -568,7 +568,7 @@ public final class FieldSpec {
                         fieldPrefix, camelCaseName(), fieldPrefix, camelCaseName());
                 }
             }
-        } else if (type().isString() || type().isStruct()) {
+        } else if (type().isString() || type().isStruct() || type() instanceof FieldType.UUIDFieldType) {
             if (fieldDefault.equals("null")) {
                 buffer.printf("if (%s%s != null) {%n", fieldPrefix, camelCaseName());
             } else if (nullableVersions.empty()) {