diff options
-rw-r--r-- | cpp/src/qpid/broker/SessionAdapter.cpp | 27 | ||||
-rw-r--r-- | python/tests_0-10/query.py | 5 |
2 files changed, 21 insertions, 11 deletions
diff --git a/cpp/src/qpid/broker/SessionAdapter.cpp b/cpp/src/qpid/broker/SessionAdapter.cpp index 1830b2b94c..9a90c2d970 100644 --- a/cpp/src/qpid/broker/SessionAdapter.cpp +++ b/cpp/src/qpid/broker/SessionAdapter.cpp @@ -220,17 +220,22 @@ bool SessionAdapter::QueueHandlerImpl::isLocal(const ConnectionToken* t) const QueueQueryResult SessionAdapter::QueueHandlerImpl::query(const string& name) { - Queue::shared_ptr queue = getQueue(name); - Exchange::shared_ptr alternateExchange = queue->getAlternateExchange(); - - return QueueQueryResult(queue->getName(), - alternateExchange ? alternateExchange->getName() : "", - queue->isDurable(), - queue->hasExclusiveOwner(), - queue->isAutoDelete(), - queue->getSettings(), - queue->getMessageCount(), - queue->getConsumerCount()); + Queue::shared_ptr queue = session.getBroker().getQueues().find(name); + if (queue) { + + Exchange::shared_ptr alternateExchange = queue->getAlternateExchange(); + + return QueueQueryResult(queue->getName(), + alternateExchange ? alternateExchange->getName() : "", + queue->isDurable(), + queue->hasExclusiveOwner(), + queue->isAutoDelete(), + queue->getSettings(), + queue->getMessageCount(), + queue->getConsumerCount()); + } else { + return QueueQueryResult(); + } } void SessionAdapter::QueueHandlerImpl::declare(const string& name, const string& alternateExchange, diff --git a/python/tests_0-10/query.py b/python/tests_0-10/query.py index 0bbfb079cc..311df84096 100644 --- a/python/tests_0-10/query.py +++ b/python/tests_0-10/query.py @@ -30,6 +30,11 @@ class QueryTests(TestBase010): result = session.queue_query(queue="my-queue") self.assertEqual("my-queue", result.queue) + def test_queue_query_unknown(self): + session = self.session + result = session.queue_query(queue="I don't exist") + self.assert_(not result.queue) + def test_exchange_query(self): """ Test that the exchange_query method works as expected |