hangc0276 commented on code in PR #4293: URL: https://github.com/apache/bookkeeper/pull/4293#discussion_r1614961486
########## bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java: ########## @@ -700,14 +700,10 @@ void writeLac(final long ledgerId, final byte[] masterKey, final long lac, ByteB .setVersion(ProtocolVersion.VERSION_THREE) .setOperation(OperationType.WRITE_LAC) .setTxnId(txnId); - ByteString body; - if (toSend.hasArray()) { - body = UnsafeByteOperations.unsafeWrap(toSend.array(), toSend.arrayOffset(), toSend.readableBytes()); - } else if (toSend.size() == 1) { - body = UnsafeByteOperations.unsafeWrap(toSend.getBuffer(0).nioBuffer()); - } else { - body = UnsafeByteOperations.unsafeWrap(toSend.toArray()); - } + ByteString body = ByteStringUtil.byteBufListToByteString(toSend); + toSend.retain(); Review Comment: We already converted toSend to ByteString, the lifecycle of `toSend` can be tracked by the caller of the method. -- 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