DL1231 commented on code in PR #20614: URL: https://github.com/apache/kafka/pull/20614#discussion_r2558156454
########## clients/src/test/java/org/apache/kafka/common/message/ProtocolSerializationConsistencyTest.java: ########## @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kafka.common.message; + +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.protocol.ByteBufferAccessor; +import org.apache.kafka.common.protocol.ObjectSerializationCache; +import org.apache.kafka.common.protocol.types.Field; +import org.apache.kafka.common.protocol.types.Struct; +import org.apache.kafka.common.record.MemoryRecords; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.ByteBuffer; +import java.util.List; +import java.util.TreeMap; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ProtocolSerializationConsistencyTest { + + private Struct nonFlexibleStruct; + + private Struct flexibleStruct; + + private AllTypeMessageData messageData; + + @BeforeEach + public void setup() { + nonFlexibleStruct = new Struct(AllTypeMessageData.SCHEMA_0) + .set("my_boolean", false) Review Comment: It appears that Struct does not have default values. If we don't explicitly set the value, it will throw an exception: <pre> Error computing size for field 'my_boolean': Missing value for field 'my_boolean' which has no default value. org.apache.kafka.common.protocol.types.SchemaException: Error computing size for field 'my_boolean': Missing value for field 'my_boolean' which has no default value. at app//org.apache.kafka.common.protocol.types.Schema.sizeOf(Schema.java:141) at app//org.apache.kafka.common.protocol.types.Struct.sizeOf(Struct.java:201) at app//org.apache.kafka.common.message.ProtocolSerializationConsistencyTest.checkSchemaAndMessageSerializationConsistency(ProtocolSerializationConsistencyTest.java:154) at app//org.apache.kafka.common.message.ProtocolSerializationConsistencyTest.testNonFlexibleWithNullValue(ProtocolSerializationConsistencyTest.java:99) </pre> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
