BewareMyPower commented on code in PR #23983:
URL: https://github.com/apache/pulsar/pull/23983#discussion_r1955458077
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -671,8 +671,15 @@ public void updateSubscribeRateLimiter() {
}
private void asyncAddEntry(ByteBuf headersAndPayload, PublishContext
publishContext) {
- ledger.asyncAddEntry(headersAndPayload,
- (int) publishContext.getNumberOfMessages(), this, publishContext);
+ // Retain the buffer in advance to avoid the buffer might have been
released when it's passed to `asyncAddEntry`
+ final var buffer = headersAndPayload.retain();
Review Comment:
BTW, I will reuse the `PersistentTopicTest#testPublishMessage` to verify the
reference count after the publish is done.
--
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]