Skip to content

Commit 47ec85e

Browse files
committed
fix log after client close
1 parent 23b60d1 commit 47ec85e

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

lib/ConsumerImpl.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,26 @@ ConsumerImpl::~ConsumerImpl() {
186186
// consumer seek, caused reconnection, if consumer close happened before connection ready,
187187
// then consumer will not send closeConsumer to Broker side, and caused a leak of consumer in
188188
// broker.
189-
LOG_WARN(consumerStr_ << "Destroyed consumer which was not properly closed");
189+
auto client = client_.lock();
190+
if (client) {
191+
LOG_WARN(consumerStr_ << "Destroyed consumer which was not properly closed");
192+
} else {
193+
LOG_DEBUG(consumerStr_ << "Destroyed consumer which was not properly closed (client already destroyed)");
194+
}
190195

191196
ClientConnectionPtr cnx = getCnx().lock();
192197
if (cnx) {
193198
auto requestId = newRequestId();
194199
cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId), requestId,
195200
"CLOSE_CONSUMER");
196201
cnx->removeConsumer(consumerId_);
197-
LOG_INFO(consumerStr_ << "Closed consumer for race condition: " << consumerId_);
202+
LOG_DEBUG(consumerStr_ << "Closed consumer for race condition: " << consumerId_);
198203
} else {
199-
LOG_WARN(consumerStr_ << "Client is destroyed and cannot send the CloseConsumer command");
204+
if (client) {
205+
LOG_WARN(consumerStr_ << "Client is destroyed and cannot send the CloseConsumer command");
206+
} else {
207+
LOG_DEBUG(consumerStr_ << "Client is destroyed and cannot send the CloseConsumer command");
208+
}
200209
}
201210
}
202211
internalShutdown();

lib/ProducerImpl.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ ProducerImpl::~ProducerImpl() {
118118
internalShutdown();
119119
printStats();
120120
if (state_ == Ready || state_ == Pending) {
121-
LOG_WARN(producerStr_ << "Destroyed producer which was not properly closed");
121+
auto client = client_.lock();
122+
if (client) {
123+
LOG_WARN(producerStr_ << "Destroyed producer which was not properly closed");
124+
} else {
125+
LOG_DEBUG(producerStr_ << "Destroyed producer which was not properly closed (client already destroyed)");
126+
}
122127
}
123128
}
124129

@@ -753,10 +758,10 @@ void ProducerImpl::sendMessage(std::unique_ptr<OpSendMsg> opSendMsg) {
753758

754759
void ProducerImpl::printStats() {
755760
if (batchMessageContainer_) {
756-
LOG_INFO("Producer - " << producerStr_ << ", [batchMessageContainer = " << *batchMessageContainer_
761+
LOG_DEBUG("Producer - " << producerStr_ << ", [batchMessageContainer = " << *batchMessageContainer_
757762
<< "]");
758763
} else {
759-
LOG_INFO("Producer - " << producerStr_ << ", [batching = off]");
764+
LOG_DEBUG("Producer - " << producerStr_ << ", [batching = off]");
760765
}
761766
}
762767

0 commit comments

Comments
 (0)