@Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;

            ByteBufferLegacyRecordBatch that = (ByteBufferLegacyRecordBatch) o;

            return Objects.equals(buffer, that.buffer);
        }
LegacyRecordBatch does not implement this iterator and would hence fallback to the normal iterator.

@return An iterator over the records contained within this batch
clients/src/main/java/org/apache/kafka/common/record/AbstractLegacyRecordBatch.java