ijuma commented on a change in pull request #7409: URL: https://github.com/apache/kafka/pull/7409#discussion_r536212437
########## 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: There is a reasonable argument that `serializeBody` is the counterpart to `parse` though and this particular method doesn't have to be here. I can buy that. ---------------------------------------------------------------- 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