hachikuji commented on a change in pull request #9619: URL: https://github.com/apache/kafka/pull/9619#discussion_r526584156
########## File path: clients/src/main/java/org/apache/kafka/common/protocol/SendBuilder.java ########## @@ -130,13 +139,25 @@ public void writeVarlong(long i) { */ @Override public void writeRecords(BaseRecords records) { - flushCurrentBuffer(); - sends.add(records.toSend(destinationId)); + flushPendingBuffer(); + + if (records instanceof MemoryRecords) { + buffers.add(((MemoryRecords) records).buffer()); + } else { + flushPendingSend(); + sends.add(records.toSend(destinationId)); Review comment: That's fair. `FetchResponse` is the only case where we would use a different `Records` type, so may as well optimize for the common case. ---------------------------------------------------------------- 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