qianye1001 commented on PR #10555: URL: https://github.com/apache/rocketmq/pull/10555#issuecomment-4831896085
One note on the safety comment: `Message.build()` does not consume or copy the `ByteString`. With `UnsafeByteOperations.unsafeWrap(messageExt.getBody())`, the built protobuf `Message` still aliases the original `byte[]`. I verified this with a small local probe: mutating the source body after `buildMessage()` is reflected in `grpcMessage.getBody()`. The current receive path still looks safe to me because `MessageDecoder.decode()` allocates a fresh body array, and the later receive-path code only updates receipt/properties, not the body bytes. So I do not see this as a blocker, but I suggest adjusting the comment to document the real invariant: the decoded body array must not be mutated or reused while the returned protobuf message may still be used or serialized. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
