Details
-
Improvement
-
Status: Patch Available
-
Major
-
Resolution: Unresolved
-
2.3.0
-
None
Description
Code in ByteBufferSerializer#serialize like this
public byte[] serialize(String topic, ByteBuffer data) { if (data == null) return null; data.rewind(); if (data.hasArray()) { byte[] arr = data.array(); if (data.arrayOffset() == 0 && arr.length == data.remaining()) { return arr; } } byte[] ret = new byte[data.remaining()]; data.get(ret, 0, ret.length); data.rewind(); return ret; }
Temp byte array will be created when use with DirectByteBuffer, how about declare a method such as serialize2Buffer and return the ByteBuffer directly ? This can improve GC a lot in KafkaProducer.
Attachments
Issue Links
- links to