qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1626206 - in /qpid/trunk/qpid/cpp/src/qpid/broker: ExchangeRegistry.cpp ExchangeRegistry.h amqp/NodePolicy.cpp
Date Fri, 19 Sep 2014 13:28:18 GMT
Author: gsim
Date: Fri Sep 19 13:28:17 2014
New Revision: 1626206

URL: http://svn.apache.org/r1626206
Log:
QPID-5590: handle unknown exchange type for topic policy

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.h
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp?rev=1626206&r1=1626205&r2=1626206&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp Fri Sep 19 13:28:17 2014
@@ -72,7 +72,7 @@ pair<Exchange::shared_ptr, bool> Exchang
             }else{
                 FunctionMap::iterator i =  factory.find(type);
                 if (i == factory.end()) {
-                    throw UnknownExchangeTypeException();
+                    throw UnknownExchangeTypeException(type);
                 } else {
                     exchange = i->second(name, durable, autodelete, args, parent, broker);
                 }
@@ -155,6 +155,16 @@ void ExchangeRegistry::registerType(cons
     factory[type] = f;
 }
 
+void ExchangeRegistry::checkType(const std::string& type)
+{
+    if (type != TopicExchange::typeName && type != DirectExchange::typeName &&
type != FanOutExchange::typeName
+        && type != HeadersExchange::typeName && type != ManagementDirectExchange::typeName
+        && type != ManagementTopicExchange::typeName && type != Link::exchangeTypeName
+        && factory.find(type) == factory.end()) {
+        throw UnknownExchangeTypeException(type);
+    }
+}
+
 
 namespace
 {

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.h?rev=1626206&r1=1626205&r2=1626206&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.h Fri Sep 19 13:28:17 2014
@@ -37,8 +37,20 @@
 
 namespace qpid {
 namespace broker {
-
-struct UnknownExchangeTypeException{};
+namespace {
+const std::string UNKNOWN_EXCHANGE_TYPE("Unknown exchange type: ");
+}
+
+struct UnknownExchangeTypeException : std::exception
+{
+    const std::string message;
+    UnknownExchangeTypeException(const std::string& type) throw() : message(UNKNOWN_EXCHANGE_TYPE
+ type) {}
+    ~UnknownExchangeTypeException() throw() {}
+    const char* what() const throw()
+    {
+        return message.c_str();
+    }
+};
 
 class ExchangeRegistry{
   public:
@@ -89,6 +101,8 @@ class ExchangeRegistry{
 
     QPID_BROKER_EXTERN void registerType(const std::string& type, FactoryFunction);
 
+    QPID_BROKER_EXTERN void checkType(const std::string& type);
+
     /** Call f for each exchange in the registry. */
     template <class F> void eachExchange(F f) const {
         qpid::sys::RWlock::ScopedRlock l(lock);

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp?rev=1626206&r1=1626205&r2=1626206&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp Fri Sep 19 13:28:17 2014
@@ -160,6 +160,8 @@ TopicPolicy::TopicPolicy(Broker& broker,
     : NodePolicy(TOPIC_POLICY, pattern, props), exchangeType(getProperty(EXCHANGE_TYPE, props)),
       autodelete(get(AUTO_DELETE, props, !durable))
 {
+    if (exchangeType.empty()) exchangeType = TOPIC;
+    broker.getExchanges().checkType(exchangeType);
     qpid::types::Variant::Map::const_iterator i = props.find(LIFETIME_POLICY);
     if (i != props.end()) {
         if (i->second == MANUAL) {
@@ -173,7 +175,6 @@ TopicPolicy::TopicPolicy(Broker& broker,
     topicSettings = filterForTopic(props);
     copy(QPID_IVE, props, exchangeSettings);
     copy(QPID_MSG_SEQUENCE, props, exchangeSettings);
-    if (exchangeType.empty()) exchangeType = TOPIC;
 
     qpid::management::ManagementAgent* agent = broker.getManagementAgent();
     if (agent != 0) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message