chia7712 commented on code in PR #18919: URL: https://github.com/apache/kafka/pull/18919#discussion_r1957408912
########## clients/src/main/java/org/apache/kafka/common/record/RecordsUtil.java: ########## @@ -89,10 +89,11 @@ protected static ConvertedRecords<MemoryRecords> downConvert(Iterable<? extends buffer = Utils.ensureCapacity(buffer, buffer.position() + recordBatchAndRecords.batch.sizeInBytes()); recordBatchAndRecords.batch.writeTo(buffer); } else { - MemoryRecordsBuilder builder = convertRecordBatch(toMagic, buffer, recordBatchAndRecords); - buffer = builder.buffer(); - temporaryMemoryBytes += builder.uncompressedBytesWritten(); - numRecordsConverted += builder.numRecords(); + try (MemoryRecordsBuilder builder = convertRecordBatch(toMagic, buffer, recordBatchAndRecords)) { Review Comment: Do we really need this close? the builder returned by `convertRecordBatch` is already closed. see https://github.com/apache/kafka/blob/d0e516a87207b04f6266c59712775b5f01c1ed87/clients/src/main/java/org/apache/kafka/common/record/RecordsUtil.java#L124 Additionally, `RecordsUtil` is useless in trunk and it will be removed by #18897 -- 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