activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5710 - rework fix to resolve some unit test regressions, change now confined to rar usecase
Date Fri, 10 Apr 2015 09:44:29 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 69767a2f2 -> b29eb384b


https://issues.apache.org/jira/browse/AMQ-5710 - rework fix to resolve some unit test regressions,
change now confined to rar usecase


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

Branch: refs/heads/master
Commit: b29eb384b8e6b24f2b11242f1ddb464413301e5a
Parents: 69767a2
Author: gtully <gary.tully@gmail.com>
Authored: Thu Apr 9 16:49:44 2015 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Thu Apr 9 16:50:14 2015 +0100

----------------------------------------------------------------------
 .../org/apache/activemq/ActiveMQConnection.java | 23 ++++++++----
 .../apache/activemq/ConnectionCleanupTest.java  | 38 +++++++++++++++++---
 2 files changed, 51 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/b29eb384/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
index d87118d..87e4c91 100755
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
@@ -1572,7 +1572,10 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
      * connection.
      */
     public void cleanup() throws JMSException {
+        doCleanup(false);
+    }
 
+    public void doCleanup(boolean removeConnection) throws JMSException {
         if (advisoryConsumer != null && !isTransportFailed()) {
             advisoryConsumer.dispose();
             advisoryConsumer = null;
@@ -1587,13 +1590,21 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
             c.dispose();
         }
 
-        if (userSpecifiedClientID) {
-            info.setClientId(null);
-            userSpecifiedClientID = false;
+        if (removeConnection) {
+            if (isConnectionInfoSentToBroker) {
+                if (!transportFailed.get() && !closing.get()) {
+                    syncSendPacket(info.createRemoveCommand());
+                }
+                isConnectionInfoSentToBroker = false;
+            }
+            if (userSpecifiedClientID) {
+                info.setClientId(null);
+                userSpecifiedClientID = false;
+            }
+            clientIDSet = false;
         }
-        clientIDSet = false;
 
-        stop();
+        started.set(false);
     }
 
     /**
@@ -1983,7 +1994,7 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
                     ServiceSupport.dispose(ActiveMQConnection.this.transport);
                     brokerInfoReceived.countDown();
                     try {
-                        cleanup();
+                        doCleanup(true);
                     } catch (JMSException e) {
                         LOG.warn("Exception during connection cleanup, " + e, e);
                     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/b29eb384/activemq-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
index f7a64ac..39be83b 100755
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
@@ -29,7 +29,7 @@ public class ConnectionCleanupTest extends TestCase {
     private ActiveMQConnection connection;
 
     protected void setUp() throws Exception {
-        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
         connection = (ActiveMQConnection)factory.createConnection();
     }
 
@@ -50,18 +50,48 @@ public class ConnectionCleanupTest extends TestCase {
 
         try {
             connection.setClientID("test");
-            // fail("Should have received JMSException");
+            fail("Should have received JMSException");
         } catch (JMSException e) {
         }
 
-        connection.cleanup();
+        connection.doCleanup(true);
+
+        connection.setClientID("test");
+
+        connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        try {
+            connection.setClientID("test");
+            fail("Should have received JMSException");
+        } catch (JMSException e) {
+        }
+
+    }
+
+    public void testChangeClientIDDenied() throws JMSException {
+
         connection.setClientID("test");
+        connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        try {
+            connection.setClientID("test");
+            fail("Should have received JMSException");
+        } catch (JMSException e) {
+        }
+
+        connection.cleanup();
+
+        try {
+            connection.setClientID("test");
+            fail("Should have received JMSException");
+        } catch (JMSException e) {
+        }
 
         connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         try {
             connection.setClientID("test");
-            // fail("Should have received JMSException");
+            fail("Should have received JMSException");
         } catch (JMSException e) {
         }
     }


Mime
View raw message