Rancho-7 commented on code in PR #19346: URL: https://github.com/apache/kafka/pull/19346#discussion_r2050184886
########## raft/src/main/java/org/apache/kafka/raft/internals/RecordsIterator.java: ########## @@ -358,17 +355,6 @@ private static ControlRecord decodeControlRecord(Optional<ByteBuffer> key, Optio throw new IllegalArgumentException("Got an unexpected empty value in the record"); } - ControlRecordType type = ControlRecordType.parse(key.get()); - - final ApiMessage message = switch (type) { - case LEADER_CHANGE -> ControlRecordUtils.deserializeLeaderChangeMessage(value.get()); - case SNAPSHOT_HEADER -> ControlRecordUtils.deserializeSnapshotHeaderRecord(value.get()); - case SNAPSHOT_FOOTER -> ControlRecordUtils.deserializeSnapshotFooterRecord(value.get()); - case KRAFT_VERSION -> ControlRecordUtils.deserializeKRaftVersionRecord(value.get()); - case KRAFT_VOTERS -> ControlRecordUtils.deserializeVotersRecord(value.get()); - default -> throw new IllegalArgumentException(String.format("Unknown control record type %s", type)); - }; - - return new ControlRecord(type, message); + return ControlRecord.of(key, value); Review Comment: You're right, since `keySize` and `valueSize` will always be >= 0 in a control batch, we can remove the duplicate check. -- 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