Skip to content

Commit

Permalink
KAFKA-12321 the comparison function for uuid type should be 'equals' …
Browse files Browse the repository at this point in the history
…rather than '==' (#10098)

Reviewers: Ismael Juma <ismael@juma.me.uk>
  • Loading branch information
chia7712 committed Feb 12, 2021
1 parent b419d1c commit 07e2b56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
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;
Expand Down Expand Up @@ -749,6 +750,13 @@ public void testProduceResponseVersions() throws Exception {
}
}

@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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void generateNonDefaultValueCheck(HeaderGenerator headerGenerator,
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()) {
Expand Down

0 comments on commit 07e2b56

Please sign in to comment.