lhotari commented on code in PR #4293: URL: https://github.com/apache/bookkeeper/pull/4293#discussion_r1613017855
########## 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: The ByteString doesn't handle the lifecycle of the buffers referenced by the ByteString. It's the `toSend.retain()` which handles the lifecycle. The `cleanupActionFailedBeforeWrite` and `cleanupActionAfterWrite` parameters (`Runnable`s) are used to ensure that the reference count is properly decreased later. -- 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