Parkerhiphop commented on code in PR #24239:
URL: https://github.com/apache/kafka/pull/24239#discussion_r4703218559
##########
metadata/src/main/java/org/apache/kafka/metadata/util/SnapshotFileReader.java:
##########
@@ -127,37 +130,41 @@ public OptionalLong highWaterMark() {
}
private void handleControlBatch(FileChannelRecordBatch batch) {
- for (Record record : batch) {
- try {
- ControlRecordType type = ControlRecordType.parse(record.key());
- switch (type) {
- case LEADER_CHANGE:
+ try (CloseableIterator<Record> iterator =
batch.streamingIterator(BufferSupplier.NO_CACHING)) {
+ while (iterator.hasNext()) {
+ Record record = iterator.next();
+ try {
+ ControlRecordType type =
ControlRecordType.parse(record.key());
+ if (Objects.requireNonNull(type) ==
ControlRecordType.LEADER_CHANGE) {
Review Comment:
Yes. I agree the switch pattern would be more readable. Adopted it!
--
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]