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:08:28 UTC

[kafka] branch trunk 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 trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


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

commit 2294d1040504f871290293131f2b98a76f1d93d3
Author: Chia-Ping Tsai <ch...@gmail.com>
AuthorDate: Sat Feb 13 00:07:19 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    | 8 ++++++++
 generator/src/main/java/org/apache/kafka/message/FieldSpec.java   | 2 +-
 2 files changed, 9 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 52cd338..5dc379e 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
@@ -49,6 +49,7 @@ import org.apache.kafka.common.protocol.ApiKeys;
 import org.apache.kafka.common.protocol.ByteBufferAccessor;
 import org.apache.kafka.common.protocol.Errors;
 import org.apache.kafka.common.protocol.Message;
+import org.apache.kafka.common.protocol.MessageUtil;
 import org.apache.kafka.common.protocol.ObjectSerializationCache;
 import org.apache.kafka.common.protocol.types.RawTaggedField;
 import org.junit.jupiter.api.Test;
@@ -750,6 +751,13 @@ public final class MessageTest {
     }
 
     @Test
+    public void defaultValueShouldBeWritable() {
+        for (short version = SimpleExampleMessageData.LOWEST_SUPPORTED_VERSION; version <= SimpleExampleMessageData.HIGHEST_SUPPORTED_VERSION; ++version) {
+            MessageUtil.toByteBuffer(new SimpleExampleMessageData(), 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 0f31ba0..d15b03c 100644
--- a/generator/src/main/java/org/apache/kafka/message/FieldSpec.java
+++ b/generator/src/main/java/org/apache/kafka/message/FieldSpec.java
@@ -589,7 +589,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()) {