ijuma commented on a change in pull request #9714: URL: https://github.com/apache/kafka/pull/9714#discussion_r539323586
########## File path: clients/src/main/java/org/apache/kafka/common/network/SizeDelimitedSend.java ########## @@ -14,18 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package org.apache.kafka.common.protocol; +package org.apache.kafka.common.network; import java.nio.ByteBuffer; -public final class MessageTestUtil { - public static ByteBuffer messageToByteBuffer(Message message, short version) { - ObjectSerializationCache cache = new ObjectSerializationCache(); - int size = message.size(cache, version); - ByteBuffer bytes = ByteBuffer.allocate(size); - message.write(new ByteBufferAccessor(bytes), cache, version); - bytes.rewind(); - return bytes; +/** + * A size delimited Send that consists of a 4 byte network-ordered size N followed by N bytes of content. + */ +public class SizeDelimitedSend extends ByteBufferSend { Review comment: It has to be a `Send` too. I looked at this a bit closer and we can just return `ByteBufferSend` from the static factory method. The thing I attempted before was to combine at the `NetworkSend` level and that doesn't work since `NetworkSend` can work with `Send`s that are not backed by a `ByteBuffer`. But it actually works fine at `ByteBufferSend` level. Thanks for the suggestion, please check the update. ---------------------------------------------------------------- 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