merlimat commented on a change in pull request #8283:
URL: https://github.com/apache/pulsar/pull/8283#discussion_r506752681



##########
File path: pulsar-client-cpp/lib/Commands.cc
##########
@@ -675,7 +675,7 @@ uint64_t 
Commands::serializeSingleMessageInBatchWithPayload(const Message& msg,
                   << batchPayLoad.writableBytes() << "] can't accomodate new 
payload [" << requiredSpace
                   << "] - expanding the batchPayload buffer");
         SharedBuffer buffer = 
SharedBuffer::allocate(batchPayLoad.readableBytes() +
-                                                     std::max(requiredSpace, 
maxMessageSizeInBytes));
+                                                     std::min(requiredSpace, 
maxMessageSizeInBytes));

Review comment:
       The `SharedBuffer` class doesn't automatically expand on writes (since 
it could be just wrapping a memory pointer instead of owning the underlying 
array). Logically, the `max()` was wrong here, though it could just use 
`requiredSpace` directly instead because the size check (<maxMessageSize) would 
have been done before, I guess.




----------------------------------------------------------------
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]


Reply via email to