qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r585503 - in /incubator/qpid/trunk/qpid: cpp/src/qpid/broker/HeadersExchange.cpp cpp/src/tests/HeadersExchangeTest.cpp python/tests_0-10/exchange.py
Date Wed, 17 Oct 2007 13:45:28 GMT
Author: gsim
Date: Wed Oct 17 06:45:27 2007
New Revision: 585503

URL: http://svn.apache.org/viewvc?rev=585503&view=rev
Log:
Fix to headers exchanges bind: need to check the match value is present before dereferencing
Added tests for this.


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp
    incubator/qpid/trunk/qpid/cpp/src/tests/HeadersExchangeTest.cpp
    incubator/qpid/trunk/qpid/python/tests_0-10/exchange.py

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp?rev=585503&r1=585502&r2=585503&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/HeadersExchange.cpp Wed Oct 17 06:45:27
2007
@@ -46,7 +46,7 @@
 bool HeadersExchange::bind(Queue::shared_ptr queue, const string& /*routingKey*/, const
FieldTable* args){
     RWlock::ScopedWlock locker(lock);
     FieldTable::ValuePtr what = args->get(x_match);
-    if (*what != all && *what != any) {
+    if (!what || (*what != all && *what != any)) {
         THROW_QPID_ERROR(PROTOCOL_ERROR, "Invalid x-match value binding to headers exchange.");
     }
     Binding binding(*args, queue);

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/HeadersExchangeTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/HeadersExchangeTest.cpp?rev=585503&r1=585502&r2=585503&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/HeadersExchangeTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/HeadersExchangeTest.cpp Wed Oct 17 06:45:27 2007
@@ -19,6 +19,7 @@
  *
  */
 
+#include "qpid/QpidError.h"
 #include "qpid/broker/HeadersExchange.h"
 #include "qpid/framing/FieldTable.h"
 #include "qpid/framing/FieldValue.h"
@@ -35,6 +36,7 @@
     CPPUNIT_TEST(testMatchEmptyValue);
     CPPUNIT_TEST(testMatchEmptyArgs);
     CPPUNIT_TEST(testMatchNoXMatch);
+    CPPUNIT_TEST(testBindNoXMatch);
     CPPUNIT_TEST_SUITE_END();
 
   public:
@@ -105,6 +107,20 @@
         b.setString("foo", "FOO");
         m.setString("foo", "FOO");
         CPPUNIT_ASSERT(!HeadersExchange::match(b, m));
+    }
+    
+    void testBindNoXMatch() 
+    {
+        HeadersExchange exchange("test");
+        Queue::shared_ptr queue;
+        std::string key;
+        FieldTable args;
+        try {
+            //just checking this doesn't cause assertion etc
+            exchange.bind(queue, key, &args);
+        } catch(qpid::QpidError&) {
+            //expected
+        }
     }
     
     

Modified: incubator/qpid/trunk/qpid/python/tests_0-10/exchange.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests_0-10/exchange.py?rev=585503&r1=585502&r2=585503&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests_0-10/exchange.py (original)
+++ incubator/qpid/trunk/qpid/python/tests_0-10/exchange.py Wed Oct 17 06:45:27 2007
@@ -325,3 +325,11 @@
         c2.session_open()
         c2.exchange_delete(exchange="test_different_declared_type_exchange")
     
+class ExchangeTests(TestBase):
+    def testHeadersBindNoMatchArg(self):
+        self.channel.queue_declare(queue="q", exclusive=True, auto_delete=True)
+        try: 
+            self.channel.queue_bind(queue="q", exchange="amq.match", arguments={"name":"fred"
, "age":3} )
+            self.fail("Expected failure for missing x-match arg.")
+        except Closed, e:    
+            self.assertConnectionException(541, e.args[0])



Mime
View raw message