rdhabalia commented on a change in pull request #5442: [pulsar-client] Avoid
leak on publish failure on batch message
URL: https://github.com/apache/pulsar/pull/5442#discussion_r337818671
##########
File path:
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
##########
@@ -468,10 +468,13 @@ private void doBatchSendAndAdd(MessageImpl<T> msg,
SendCallback callback, ByteBu
log.debug("[{}] [{}] Closing out batch to accommodate large
message with size {}", topic, producerName,
msg.getDataBuffer().readableBytes());
}
- batchMessageAndSend();
- batchMessageContainer.add(msg, callback);
- lastSendFuture = callback.getFuture();
- payload.release();
+ try {
+ batchMessageAndSend();
+ batchMessageContainer.add(msg, callback);
+ lastSendFuture = callback.getFuture();
+ } finally {
Review comment:
yes, we trigger the callback but we missed to reduce to refCnt of `payload`
in producer so, when [callback receives
callback](https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L257),
it tries to release payload with refCnt=2 so, producer doesn't release the
actual payload.
----------------------------------------------------------------
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