Skip to content

Commit

Permalink
bugfix: check callback to avoid std::bad_function_call exception
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-min committed Nov 22, 2024
1 parent 3efa80a commit b91d537
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/AckGroupingTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,19 @@ class AckGroupingTracker : public std::enable_shared_from_this<AckGroupingTracke
* @param[in] msgId ID of the message to be ACKed.
* @param[in] callback the callback that is triggered when the message is acknowledged
*/
virtual void addAcknowledge(const MessageId& msgId, ResultCallback callback) { callback(ResultOk); }
virtual void addAcknowledge(const MessageId& msgId, ResultCallback callback) {
if (callback)
callback(ResultOk);
}

/**
* Adding message ID list into ACK group for individual ACK.
* @param[in] msgIds of the message to be ACKed.
* @param[in] callback the callback that is triggered when the messages are acknowledged
*/
virtual void addAcknowledgeList(const MessageIdList& msgIds, ResultCallback callback) {
callback(ResultOk);
if (callback)
callback(ResultOk);
}

/**
Expand All @@ -88,7 +92,8 @@ class AckGroupingTracker : public std::enable_shared_from_this<AckGroupingTracke
* @param[in] callback the callback that is triggered when the message is acknowledged
*/
virtual void addAcknowledgeCumulative(const MessageId& msgId, ResultCallback callback) {
callback(ResultOk);
if (callback)
callback(ResultOk);
}

/**
Expand Down

0 comments on commit b91d537

Please sign in to comment.