This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push: new d59a6ed Use testDupConsumersOnSharedModeNotThrowsExcOnUnsubscribe to avoid interference with other tests running in parallel (#3521) d59a6ed is described below commit d59a6ed57660e246bdab4367387a127560552da1 Author: Matteo Merli <mme...@apache.org> AuthorDate: Thu Feb 7 08:47:30 2019 -0800 Use testDupConsumersOnSharedModeNotThrowsExcOnUnsubscribe to avoid interference with other tests running in parallel (#3521) * Use testDupConsumersOnSharedModeNotThrowsExcOnUnsubscribe to avoid interference with other tests running in parallel * Fixed formatting --- pulsar-client-cpp/lib/ClientImpl.cc | 5 +++-- pulsar-client-cpp/tests/BasicEndToEndTest.cc | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pulsar-client-cpp/lib/ClientImpl.cc b/pulsar-client-cpp/lib/ClientImpl.cc index e489a24..7cc818b 100644 --- a/pulsar-client-cpp/lib/ClientImpl.cc +++ b/pulsar-client-cpp/lib/ClientImpl.cc @@ -342,10 +342,11 @@ void ClientImpl::subscribeAsync(const std::string& topic, const std::string& con return; } else if (conf.getConsumerType() == ConsumerShared) { ConsumersList consumers(consumers_); - for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) { - ConsumerImplBasePtr consumer = it->lock(); + for (auto& weakPtr : consumers) { + ConsumerImplBasePtr consumer = weakPtr.lock(); if (consumer && consumer->getSubscriptionName() == consumerName && !consumer->isClosed()) { lock.unlock(); + LOG_INFO("Reusing existing consumer instance for " << topic << " -- " << consumerName); callback(ResultOk, Consumer(consumer)); return; } diff --git a/pulsar-client-cpp/tests/BasicEndToEndTest.cc b/pulsar-client-cpp/tests/BasicEndToEndTest.cc index fdab383..a26df16 100644 --- a/pulsar-client-cpp/tests/BasicEndToEndTest.cc +++ b/pulsar-client-cpp/tests/BasicEndToEndTest.cc @@ -2782,7 +2782,8 @@ TEST(BasicEndToEndTest, testDupConsumersOnSharedModeNotThrowsExcOnUnsubscribe) { ClientConfiguration config; Client client(lookupUrl); std::string subsName = "my-only-sub"; - std::string topicName = "persistent://public/default/test-prevent-dup-consumers"; + std::string topicName = + "persistent://public/default/testDupConsumersOnSharedModeNotThrowsExcOnUnsubscribe"; ConsumerConfiguration consumerConf; consumerConf.setConsumerType(ConsumerShared);