ijuma commented on a change in pull request #7409: URL: https://github.com/apache/kafka/pull/7409#discussion_r536211422
########## 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: This method serializes the request with the header while the test method serializes the header only. So, not a duplicate, right? Personally, I think it's useful for the class to be symmetric: it can parse from a buffer and serialize to a buffer. Do you have a concern that it may be misused? ---------------------------------------------------------------- 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