merlimat commented on a change in pull request #5443: [pulsar-client] Fix
message corruption on OOM for batch messages
URL: https://github.com/apache/pulsar/pull/5443#discussion_r337778928
##########
File path:
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java
##########
@@ -82,11 +82,32 @@ public void add(MessageImpl<?> msg, SendCallback callback)
{
}
private ByteBuf getCompressedBatchMetadataAndPayload() {
- for (MessageImpl<?> msg : messages) {
+ batchedMessageMetadataAndPayload.markWriterIndex();
+ batchedMessageMetadataAndPayload.markReaderIndex();
Review comment:
Instead of marking the index of the buffer, I think we can store the indexes
into local variables.
The primary reason, is that when we pass the buffer to another function, we
don't know whether it will call `markWriterIndex()` again, and these calls are
not stacked.
Using local variables should avoid this possible trap down the road.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services