divijvaidya commented on code in PR #12228: URL: https://github.com/apache/kafka/pull/12228#discussion_r1159588380
########## clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java: ########## @@ -679,12 +678,13 @@ public static MemoryRecords withRecords(byte magic, long initialOffset, Compress long logAppendTime = RecordBatch.NO_TIMESTAMP; if (timestampType == TimestampType.LOG_APPEND_TIME) logAppendTime = System.currentTimeMillis(); - MemoryRecordsBuilder builder = new MemoryRecordsBuilder(bufferStream, magic, compressionType, timestampType, + try (final MemoryRecordsBuilder builder = new MemoryRecordsBuilder(bufferStream, magic, compressionType, timestampType, Review Comment: Note to reviewer(s): `builder.build()` calls the `MemoryRecordsBuilder#close()` method, hence, this is not a leak in happy cases. But it will not call `close()` in case exception occurs at `builder.append()`, hence, MemoryRecordsBuilder will not be closed when an exception is thrown. -- 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