activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQCPP-513
Date Fri, 20 Sep 2013 21:52:19 GMT
Updated Branches:
  refs/heads/trunk 8c0f341a4 -> 021798b68


https://issues.apache.org/jira/browse/AMQCPP-513

Apply patch and create an integration test from the provided test app to
prevent this from popping up again. 

Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/021798b6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/021798b6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/021798b6

Branch: refs/heads/trunk
Commit: 021798b68a3154effc45a877de84966fd5750774
Parents: 8c0f341
Author: Timothy Bish <tabish121@gmai.com>
Authored: Fri Sep 20 17:52:10 2013 -0400
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Fri Sep 20 17:52:10 2013 -0400

----------------------------------------------------------------------
 .../main/activemq/core/ActiveMQConnection.cpp   |  4 ++
 .../src/main/activemq/core/AdvisoryConsumer.cpp |  2 +-
 .../test/openwire/OpenwireAdvisorysTest.cpp     | 66 ++++++++++++++++++++
 .../test/openwire/OpenwireAdvisorysTest.h       |  2 +
 4 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/021798b6/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
index a8e518d..4aa9106 100644
--- a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
+++ b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
@@ -738,6 +738,10 @@ void ActiveMQConnection::close() {
 
         // As TemporaryQueue and TemporaryTopic instances are bound to a connection
         // we should just delete them after the connection is closed to free up memory
+        if (this->config->advisoryConsumer != NULL) {
+            this->config->advisoryConsumer->dispose();
+        }
+
         ArrayList<Pointer<ActiveMQTempDestination> > tempDests(this->config->activeTempDestinations.values());
         Pointer<Iterator<Pointer<ActiveMQTempDestination> > > iterator(tempDests.iterator());
 

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/021798b6/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp b/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp
index 2268cf1..8608fbe 100644
--- a/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp
+++ b/activemq-cpp/src/main/activemq/core/AdvisoryConsumer.cpp
@@ -92,7 +92,7 @@ AdvisoryConsumer::~AdvisoryConsumer() {
 ////////////////////////////////////////////////////////////////////////////////
 void AdvisoryConsumer::dispose() {
 
-    if (!this->config->closed.compareAndSet(false, true)) {
+    if (this->config->closed.compareAndSet(false, true)) {
 
         try {
             this->connection->oneway(this->config->info->createRemoveCommand());

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/021798b6/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.cpp
b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.cpp
index ff5eb14..9edd9f9 100644
--- a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.cpp
+++ b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.cpp
@@ -27,6 +27,8 @@
 #include <decaf/lang/exceptions/ClassCastException.h>
 #include <decaf/lang/Pointer.h>
 #include <decaf/lang/Thread.h>
+#include <decaf/lang/Runnable.h>
+#include <decaf/util/concurrent/TimeUnit.h>
 #include <decaf/util/UUID.h>
 
 #include <cms/ConnectionFactory.h>
@@ -48,6 +50,7 @@ using namespace decaf;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 using namespace decaf::util;
+using namespace decaf::util::concurrent;
 using namespace activemq;
 using namespace activemq::core;
 using namespace activemq::commands;
@@ -113,3 +116,66 @@ void OpenwireAdvisorysTest::testConnectionAdvisories() {
     connection->close();
 }
 
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class ConnectionLoadThread : public Thread {
+    private:
+
+        ConnectionFactory* factory;
+        bool noErrors;
+
+    public:
+
+        ConnectionLoadThread(ConnectionFactory* factory) :
+            Thread(), factory(factory), noErrors(true) {
+        }
+
+        virtual ~ConnectionLoadThread() {}
+
+        bool isNoErrors() const {
+            return this->noErrors;
+        }
+
+        virtual void run() {
+
+            try {
+                for (unsigned int i = 0; i < 50; ++i) {
+                    auto_ptr<Connection> connection(factory->createConnection());
+                    connection->start();
+                    auto_ptr<Session> session(connection->createSession(Session::AUTO_ACKNOWLEDGE));
+
+                    for (unsigned int j = 0; j < 100; ++j) {
+                        auto_ptr<Queue> queue(session->createTemporaryQueue());
+                        auto_ptr<MessageProducer> producer(session->createProducer(queue.get()));
+                    }
+
+                    TimeUnit::MILLISECONDS.sleep(20);
+                    connection->close();
+                }
+            } catch(...) {
+                noErrors = false;
+            }
+        }
+    };
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenwireAdvisorysTest::testConcurrentTempDestCreation() {
+
+    std::auto_ptr<ConnectionFactory> factory(
+        ConnectionFactory::createCMSConnectionFactory( getBrokerURL() ) );
+
+    ConnectionLoadThread thread1(factory.get());
+    ConnectionLoadThread thread2(factory.get());
+
+    thread1.start();
+    thread2.start();
+
+    thread1.join();
+    thread2.join();
+
+    CPPUNIT_ASSERT(thread1.isNoErrors());
+    CPPUNIT_ASSERT(thread2.isNoErrors());
+}

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/021798b6/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.h
b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.h
index 4aab653..c92ebc3 100644
--- a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.h
+++ b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireAdvisorysTest.h
@@ -31,6 +31,7 @@ namespace openwire {
 
         CPPUNIT_TEST_SUITE( OpenwireAdvisorysTest );
         CPPUNIT_TEST( testConnectionAdvisories );
+        CPPUNIT_TEST( testConcurrentTempDestCreation );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -47,6 +48,7 @@ namespace openwire {
         virtual void tearDown() {}
 
         void testConnectionAdvisories();
+        void testConcurrentTempDestCreation();
 
     };
 


Mime
View raw message