diff --git a/pulsar-client-cpp/lib/NegativeAcksTracker.cc b/pulsar-client-cpp/lib/NegativeAcksTracker.cc index e307091f6c2e8..492e379459393 100644 --- a/pulsar-client-cpp/lib/NegativeAcksTracker.cc +++ b/pulsar-client-cpp/lib/NegativeAcksTracker.cc @@ -48,14 +48,14 @@ void NegativeAcksTracker::scheduleTimer() { } void NegativeAcksTracker::handleTimer(const boost::system::error_code &ec) { - std::lock_guard lock(mutex_); - timer_ = nullptr; - if (ec) { // Ignore cancelled events return; } + std::lock_guard lock(mutex_); + timer_ = nullptr; + if (nackedMessages_.empty()) { return; }