Rancho-7 commented on code in PR #19346: URL: https://github.com/apache/kafka/pull/19346#discussion_r2051717695
########## raft/src/main/java/org/apache/kafka/raft/ControlRecord.java: ########## @@ -23,54 +23,51 @@ import org.apache.kafka.common.message.VotersRecord; import org.apache.kafka.common.protocol.ApiMessage; import org.apache.kafka.common.record.ControlRecordType; +import org.apache.kafka.common.record.ControlRecordUtils; +import java.nio.ByteBuffer; import java.util.Objects; +import java.util.Optional; + +import static org.apache.kafka.common.record.ControlRecordType.LEADER_CHANGE; public final class ControlRecord { private final ControlRecordType recordType; private final ApiMessage message; - private static void throwIllegalArgument(ControlRecordType recordType, ApiMessage message) { - throw new IllegalArgumentException( - String.format( - "Record type %s doesn't match message class %s", - recordType, - message.getClass() - ) - ); + public static ControlRecord of(Optional<ByteBuffer> key, Optional<ByteBuffer> value) { Review Comment: Great suggestion! Since we can guarantee the key and value in control record are non-null,I think the empty check seems redundant. Maybe we can directly use `ByteBuffer` instead. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org