Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
poorbarcode committed Apr 3, 2024
1 parent ca585b2 commit 68bdbb4
Showing 1 changed file with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,35 +430,23 @@ private void onSendComplete(Exception e, SendCallback sendCallback, MessageImpl<
pendingMessagesUpDownCounter.decrement();
pendingBytesUpDownCounter.subtract(msgSize);
ByteBuf payload = msg.getDataBuffer();
if (payload == null) {
log.error("[{}] [{}] Payload is null when calling onSendComplete, which is not expected.",
topic, producerName);
} else {
ReferenceCountUtil.safeRelease(payload);
}
if (e != null) {
latencyHistogram.recordFailure(latencyNanos);
stats.incrementSendFailed();
try {
onSendAcknowledgement(msg, null, e);
sendCallback.getFuture().completeExceptionally(e);
} finally {
if (payload == null) {
log.error("[{}] [{}] Payload is null when calling a failed onSendComplete, which is not"
+ " expected.", topic, producerName);
return;
}
ReferenceCountUtil.safeRelease(payload);
}
onSendAcknowledgement(msg, null, e);
sendCallback.getFuture().completeExceptionally(e);
} else {
latencyHistogram.recordSuccess(latencyNanos);
publishedBytesCounter.add(msgSize);
stats.incrementNumAcksReceived(latencyNanos);
try {
onSendAcknowledgement(msg, msg.getMessageId(), null);
sendCallback.getFuture().complete(msg.getMessageId());
} finally {
if (payload == null) {
log.error("[{}] [{}] Payload is null when calling onSendComplete, which is not expected.",
topic, producerName);
return;
}
ReferenceCountUtil.safeRelease(payload);
}
onSendAcknowledgement(msg, msg.getMessageId(), null);
sendCallback.getFuture().complete(msg.getMessageId());
}
}

Expand Down

0 comments on commit 68bdbb4

Please sign in to comment.