ijuma commented on a change in pull request #10498: URL: https://github.com/apache/kafka/pull/10498#discussion_r613777759
########## File path: clients/src/main/java/org/apache/kafka/common/record/Record.java ########## @@ -132,4 +121,16 @@ * @return the array of headers */ Header[] headers(); + + static void ensureValid(Record record) { + if (record instanceof AbstractLegacyRecordBatch) { + ((AbstractLegacyRecordBatch) record).ensureValid(); + } + } + + static boolean isValid(Record record) { + if (record instanceof AbstractLegacyRecordBatch) { + return ((AbstractLegacyRecordBatch) record).isValid(); + } else return true; Review comment: Polymorphism is a fine way to deal with that though. It's more confusing if we have a combination of polymorphism and pattern matching (well, the if/else version of it which doesn't include exhaustiveness checking). I don't see an issue with having an implementation that always return true or is a no-op for v2. A default may be ok, but it introduces more coupling between the interface and implementations. It seems that `isValid` is only used by `DumpLogSegments` (outside of tests), so we can maybe remove that altogether. I would probably leave `ensureValid` as it was before this PR. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org