ijuma commented on a change in pull request #7409: URL: https://github.com/apache/kafka/pull/7409#discussion_r537867972
########## File path: clients/src/main/java/org/apache/kafka/common/requests/AbstractRequest.java ########## @@ -95,21 +93,33 @@ public short version() { return version; } - public Send toSend(String destination, RequestHeader header) { - return new NetworkSend(destination, serialize(header)); + public ApiKeys apiKey() { + return apiKey; } - /** - * Use with care, typically {@link #toSend(String, RequestHeader)} should be used instead. - */ - public ByteBuffer serialize(RequestHeader header) { - return RequestUtils.serialize(header.toStruct(), toStruct()); + public final Send toSend(String destination, RequestHeader header) { + return SendBuilder.buildRequestSend(destination, header, data()); + } + + // Visible for testing + public final ByteBuffer serializeWithHeader(RequestHeader header) { Review comment: I have a refactoring that consolidates the logic around `Send`. But I think that would be best done in a separate PR since this PR is really massive. Since these methods are all in internal classes and are only used by tests, I suggest we keep them as they are for now and tackle these nits in the follow up 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