Author: aconway
Date: Wed Jan 11 16:57:33 2012
New Revision: 1230147

URL: http://svn.apache.org/viewvc?rev=1230147&view=rev
Log:
QPID-3603: Fix spurious "exchange not found" error and debug messages.

Modified:
    qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Exchange.cpp
    qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Queue.cpp
    qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/QueueBindings.cpp
    qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/SessionAdapter.cpp

Modified: qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Exchange.cpp
URL: 
http://svn.apache.org/viewvc/qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Exchange.cpp?rev=1230147&r1=1230146&r2=1230147&view=diff
==============================================================================
--- qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Exchange.cpp (original)
+++ qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Exchange.cpp Wed Jan 11 
16:57:33 2012
@@ -279,12 +279,10 @@ uint32_t Exchange::encodedSize() const
 void Exchange::recoveryComplete(ExchangeRegistry& exchanges)
 {
     if (!alternateName.empty()) {
-        try {
-            Exchange::shared_ptr ae = exchanges.get(alternateName);
-            setAlternate(ae);
-        } catch (const NotFoundException&) {
-            QPID_LOG(warning, "Could not set alternate exchange \"" << 
alternateName << "\": does not exist.");
-        }
+        Exchange::shared_ptr ae = exchanges.find(alternateName);
+        if (ae) setAlternate(ae);
+        else QPID_LOG(warning, "Could not set alternate exchange \""
+                      << alternateName << "\": does not exist.");
     }
 }
 

Modified: qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Queue.cpp
URL: 
http://svn.apache.org/viewvc/qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Queue.cpp?rev=1230147&r1=1230146&r2=1230147&view=diff
==============================================================================
--- qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Queue.cpp (original)
+++ qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/Queue.cpp Wed Jan 11 
16:57:33 2012
@@ -1336,12 +1336,11 @@ void Queue::recoveryComplete(ExchangeReg
 {
     // set the alternate exchange
     if (!alternateExchangeName.empty()) {
-        try {
-            Exchange::shared_ptr ae = exchanges.get(alternateExchangeName);
-            setAlternateExchange(ae);
-        } catch (const NotFoundException&) {
-            QPID_LOG(warning, "Could not set alternate exchange \"" << 
alternateExchangeName << "\" on queue \"" << name << "\": exchange does not 
exist.");
-        }
+        Exchange::shared_ptr ae = exchanges.find(alternateExchangeName);
+        if (ae) setAlternateExchange(ae);
+        else QPID_LOG(warning, "Could not set alternate exchange \""
+                      << alternateExchangeName << "\" on queue \"" << name
+                      << "\": exchange does not exist.");
     }
     //process any pending dequeues
     for_each(pendingDequeues.begin(), pendingDequeues.end(), 
boost::bind(&Queue::dequeue, this, (TransactionContext*) 0, _1));

Modified: qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/QueueBindings.cpp
URL: 
http://svn.apache.org/viewvc/qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/QueueBindings.cpp?rev=1230147&r1=1230146&r2=1230147&view=diff
==============================================================================
--- qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/QueueBindings.cpp 
(original)
+++ qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/QueueBindings.cpp Wed Jan 
11 16:57:33 2012
@@ -36,9 +36,8 @@ void QueueBindings::add(const string& ex
 void QueueBindings::unbind(ExchangeRegistry& exchanges, Queue::shared_ptr 
queue)
 {
     for (Bindings::iterator i = bindings.begin(); i != bindings.end(); i++) {
-        try {
-            exchanges.get(i->exchange)->unbind(queue, i->key, &(i->args));
-        } catch (const NotFoundException&) {}
+        Exchange::shared_ptr ex = exchanges.find(i->exchange);
+        if (ex) ex->unbind(queue, i->key, &(i->args));
     }
 }
 

Modified: qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
URL: 
http://svn.apache.org/viewvc/qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/SessionAdapter.cpp?rev=1230147&r1=1230146&r2=1230147&view=diff
==============================================================================
--- qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/SessionAdapter.cpp 
(original)
+++ qpid/branches/qpid-3603/qpid/cpp/src/qpid/broker/SessionAdapter.cpp Wed Jan 
11 16:57:33 2012
@@ -61,8 +61,8 @@ SessionAdapter::SessionAdapter(SemanticS
 static const std::string _TRUE("true");
 static const std::string _FALSE("false");
 
-void SessionAdapter::ExchangeHandlerImpl::declare(const string& exchange, 
const string& type, 
-                                                  const string& 
alternateExchange, 
+void SessionAdapter::ExchangeHandlerImpl::declare(const string& exchange, 
const string& type,
+                                                  const string& 
alternateExchange,
                                                   bool passive, bool durable, 
bool /*autoDelete*/, const FieldTable& args){
 
     //TODO: implement autoDelete
@@ -132,10 +132,10 @@ void SessionAdapter::ExchangeHandlerImpl
                       || !exchange->getAlternate()))
         throw NotAllowedException(QPID_MSG("Exchange declared with 
alternate-exchange "
                                            << (exchange->getAlternate() ? 
exchange->getAlternate()->getName() : "<nonexistent>")
-                                           << ", requested " 
+                                           << ", requested "
                                            << alternate->getName()));
 }
-                
+
 void SessionAdapter::ExchangeHandlerImpl::delete_(const string& name, bool 
/*ifUnused*/)
 {
     //TODO: implement if-unused
@@ -149,23 +149,21 @@ ExchangeQueryResult SessionAdapter::Exch
         if 
(!acl->authorise(getConnection().getUserId(),acl::ACT_ACCESS,acl::OBJ_EXCHANGE,name,NULL)
 )
             throw UnauthorizedAccessException(QPID_MSG("ACL denied exchange 
query request from " << getConnection().getUserId()));
     }
-
-    try {
-        Exchange::shared_ptr exchange(getBroker().getExchanges().get(name));
+    Exchange::shared_ptr exchange(getBroker().getExchanges().find(name));
+    if (exchange)
         return ExchangeQueryResult(exchange->getType(), exchange->isDurable(), 
false, exchange->getArgs());
-    } catch (const NotFoundException& /*e*/) {
-        return ExchangeQueryResult("", false, true, FieldTable());        
-    }
+    else
+        return ExchangeQueryResult("", false, true, FieldTable());
 }
 
-void SessionAdapter::ExchangeHandlerImpl::bind(const string& queueName, 
-                                               const string& exchangeName, 
const string& routingKey, 
+void SessionAdapter::ExchangeHandlerImpl::bind(const string& queueName,
+                                               const string& exchangeName, 
const string& routingKey,
                                                const FieldTable& arguments)
 {
     getBroker().bind(queueName, exchangeName, routingKey, arguments,
                      getConnection().getUserId(), getConnection().getUrl());
 }
- 
+
 void SessionAdapter::ExchangeHandlerImpl::unbind(const string& queueName,
                                                  const string& exchangeName,
                                                  const string& routingKey)
@@ -187,11 +185,8 @@ ExchangeBoundResult SessionAdapter::Exch
         if 
(!acl->authorise(getConnection().getUserId(),acl::ACT_ACCESS,acl::OBJ_EXCHANGE,exchangeName,&params)
 )
             throw UnauthorizedAccessException(QPID_MSG("ACL denied exchange 
bound request from " << getConnection().getUserId()));
     }
-    
-    Exchange::shared_ptr exchange;
-    try {
-        exchange = getBroker().getExchanges().get(exchangeName);
-    } catch (const NotFoundException&) {}
+
+    Exchange::shared_ptr exchange = 
getBroker().getExchanges().find(exchangeName);
 
     Queue::shared_ptr queue;
     if (!queueName.empty()) {
@@ -238,10 +233,10 @@ void SessionAdapter::QueueHandlerImpl::d
         exclusiveQueues.erase(exclusiveQueues.begin());
     }
 }
-    
-bool SessionAdapter::QueueHandlerImpl::isLocal(const ConnectionToken* t) const 
-{ 
-    return session.isLocal(t); 
+
+bool SessionAdapter::QueueHandlerImpl::isLocal(const ConnectionToken* t) const
+{
+    return session.isLocal(t);
 }
 
 
@@ -252,15 +247,15 @@ QueueQueryResult SessionAdapter::QueueHa
         if 
(!acl->authorise(getConnection().getUserId(),acl::ACT_ACCESS,acl::OBJ_QUEUE,name,NULL)
 )
             throw UnauthorizedAccessException(QPID_MSG("ACL denied queue query 
request from " << getConnection().getUserId()));
     }
-    
+
     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(), 
+
+        return QueueQueryResult(queue->getName(),
+                                alternateExchange ? 
alternateExchange->getName() : "",
+                                queue->isDurable(),
                                 queue->hasExclusiveOwner(),
                                 queue->isAutoDelete(),
                                 queue->getSettings(),
@@ -272,7 +267,7 @@ QueueQueryResult SessionAdapter::QueueHa
 }
 
 void SessionAdapter::QueueHandlerImpl::declare(const string& name, const 
string& alternateExchange,
-                                               bool passive, bool durable, 
bool exclusive, 
+                                               bool passive, bool durable, 
bool exclusive,
                                                bool autoDelete, const 
qpid::framing::FieldTable& arguments)
 {
     Queue::shared_ptr queue;
@@ -359,16 +354,16 @@ void SessionAdapter::QueueHandlerImpl::c
                                             exclusiveQueues.end(),
                                             queue);
         if (i < exclusiveQueues.end()) exclusiveQueues.erase(i);
-    }    
+    }
 }
-        
+
 void SessionAdapter::QueueHandlerImpl::delete_(const string& queue, bool 
ifUnused, bool ifEmpty)
 {
     getBroker().deleteQueue(queue, getConnection().getUserId(), 
getConnection().getUrl(),
                             
boost::bind(&SessionAdapter::QueueHandlerImpl::checkDelete, this, _1, ifUnused, 
ifEmpty));
-} 
+}
 
-SessionAdapter::MessageHandlerImpl::MessageHandlerImpl(SemanticState& s) : 
+SessionAdapter::MessageHandlerImpl::MessageHandlerImpl(SemanticState& s) :
     HandlerHelper(s),
     releaseRedeliveredOp(boost::bind(&SemanticState::release, &state, _1, _2, 
true)),
     releaseOp(boost::bind(&SemanticState::release, &state, _1, _2, false)),
@@ -405,7 +400,7 @@ SessionAdapter::MessageHandlerImpl::subs
 
     AclModule* acl = getBroker().getAcl();
     if (acl)
-    {        
+    {
          if 
(!acl->authorise(getConnection().getUserId(),acl::ACT_CONSUME,acl::OBJ_QUEUE,queueName,NULL)
 )
              throw UnauthorizedAccessException(QPID_MSG("ACL denied Queue 
subscribe request from " << getConnection().getUserId()));
     }
@@ -418,8 +413,8 @@ SessionAdapter::MessageHandlerImpl::subs
         throw ResourceLockedException(QPID_MSG("Cannot subscribe to exclusive 
queue "
                                                << queue->getName()));
 
-    state.consume(destination, queue, 
-                  acceptMode == 0, acquireMode == 0, exclusive, 
+    state.consume(destination, queue,
+                  acceptMode == 0, acquireMode == 0, exclusive,
                   resumeId, resumeTtl, arguments);
 
     ManagementAgent* agent = getBroker().getManagementAgent();
@@ -458,9 +453,9 @@ void SessionAdapter::MessageHandlerImpl:
         //unknown
         throw InvalidArgumentException(QPID_MSG("Invalid value for unit " << 
unit));
     }
-    
+
 }
-    
+
 void SessionAdapter::MessageHandlerImpl::setFlowMode(const std::string& 
destination, uint8_t mode)
 {
     if (mode == 0) {
@@ -470,18 +465,18 @@ void SessionAdapter::MessageHandlerImpl:
         //window
         state.setWindowMode(destination);
     } else{
-        throw InvalidArgumentException(QPID_MSG("Invalid value for mode " << 
mode));        
+        throw InvalidArgumentException(QPID_MSG("Invalid value for mode " << 
mode));
     }
 }
-    
+
 void SessionAdapter::MessageHandlerImpl::flush(const std::string& destination)
 {
-    state.flush(destination);        
+    state.flush(destination);
 }
 
 void SessionAdapter::MessageHandlerImpl::stop(const std::string& destination)
 {
-    state.stop(destination);        
+    state.stop(destination);
 }
 
 void SessionAdapter::MessageHandlerImpl::accept(const framing::SequenceSet& 
commands)
@@ -509,7 +504,7 @@ framing::MessageResumeResult SessionAdap
 {
     throw NotImplementedException("resuming transfers not yet supported");
 }
-    
+
 
 
 void SessionAdapter::ExecutionHandlerImpl::sync()
@@ -549,7 +544,7 @@ void SessionAdapter::TxHandlerImpl::comm
 }
 
 void SessionAdapter::TxHandlerImpl::rollback()
-{    
+{
     state.rollback();
 }
 
@@ -586,7 +581,7 @@ XaResult SessionAdapter::DtxHandlerImpl:
             return XaResult(XA_STATUS_XA_OK);
         }
     } catch (const DtxTimeoutException& /*e*/) {
-        return XaResult(XA_STATUS_XA_RBTIMEOUT);        
+        return XaResult(XA_STATUS_XA_RBTIMEOUT);
     }
 }
 
@@ -605,7 +600,7 @@ XaResult SessionAdapter::DtxHandlerImpl:
         }
         return XaResult(XA_STATUS_XA_OK);
     } catch (const DtxTimeoutException& /*e*/) {
-        return XaResult(XA_STATUS_XA_RBTIMEOUT);        
+        return XaResult(XA_STATUS_XA_RBTIMEOUT);
     }
 }
 
@@ -615,7 +610,7 @@ XaResult SessionAdapter::DtxHandlerImpl:
         bool ok = getBroker().getDtxManager().prepare(convert(xid));
         return XaResult(ok ? XA_STATUS_XA_OK : XA_STATUS_XA_RBROLLBACK);
     } catch (const DtxTimeoutException& /*e*/) {
-        return XaResult(XA_STATUS_XA_RBTIMEOUT);        
+        return XaResult(XA_STATUS_XA_RBTIMEOUT);
     }
 }
 
@@ -626,7 +621,7 @@ XaResult SessionAdapter::DtxHandlerImpl:
         bool ok = getBroker().getDtxManager().commit(convert(xid), onePhase);
         return XaResult(ok ? XA_STATUS_XA_OK : XA_STATUS_XA_RBROLLBACK);
     } catch (const DtxTimeoutException& /*e*/) {
-        return XaResult(XA_STATUS_XA_RBTIMEOUT);        
+        return XaResult(XA_STATUS_XA_RBTIMEOUT);
     }
 }
 
@@ -637,14 +632,14 @@ XaResult SessionAdapter::DtxHandlerImpl:
         getBroker().getDtxManager().rollback(convert(xid));
         return XaResult(XA_STATUS_XA_OK);
     } catch (const DtxTimeoutException& /*e*/) {
-        return XaResult(XA_STATUS_XA_RBTIMEOUT);        
+        return XaResult(XA_STATUS_XA_RBTIMEOUT);
     }
 }
 
 DtxRecoverResult SessionAdapter::DtxHandlerImpl::recover()
 {
     std::set<std::string> xids;
-    getBroker().getStore().collectPreparedXids(xids);        
+    getBroker().getStore().collectPreparedXids(xids);
     /*
      * create array of long structs
      */
@@ -665,7 +660,7 @@ void SessionAdapter::DtxHandlerImpl::for
 DtxGetTimeoutResult SessionAdapter::DtxHandlerImpl::getTimeout(const Xid& xid)
 {
     uint32_t timeout = getBroker().getDtxManager().getTimeout(convert(xid));
-    return DtxGetTimeoutResult(timeout);    
+    return DtxGetTimeoutResult(timeout);
 }
 
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscr...@qpid.apache.org

Reply via email to