lhotari commented on code in PR #4293: URL: https://github.com/apache/bookkeeper/pull/4293#discussion_r1613018156
########## bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java: ########## @@ -803,19 +807,11 @@ void addEntry(final long ledgerId, byte[] masterKey, final long entryId, Referen headerBuilder.setPriority(DEFAULT_HIGH_PRIORITY_VALUE); } - ByteString body = null; ByteBufList bufToSend = (ByteBufList) toSend; - - if (bufToSend.hasArray()) { - body = UnsafeByteOperations.unsafeWrap(bufToSend.array(), bufToSend.arrayOffset(), - bufToSend.readableBytes()); - } else { - for (int i = 0; i < bufToSend.size(); i++) { - ByteString piece = UnsafeByteOperations.unsafeWrap(bufToSend.getBuffer(i).nioBuffer()); - // use ByteString.concat to avoid byte[] allocation when toSend has multiple ByteBufs - body = (body == null) ? piece : body.concat(piece); - } - } + ByteString body = ByteStringUtil.byteBufListToByteString(bufToSend); + bufToSend.retain(); Review Comment: same answer as https://github.com/apache/bookkeeper/pull/4293#discussion_r1613017855 -- 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. To unsubscribe, e-mail: commits-unsubscr...@bookkeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org