activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6350
Date Mon, 11 Jul 2016 22:20:23 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 667ea7c64 -> 0706fd0bc


https://issues.apache.org/jira/browse/AMQ-6350

Allow for PooledConnectionFactory restart after being stopped.

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

Branch: refs/heads/master
Commit: 0706fd0bc1f499f1fc304ec1c70aa8aaa3dd4d69
Parents: 667ea7c
Author: Timothy Bish <tabish121@gmail.com>
Authored: Mon Jul 11 18:20:08 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Mon Jul 11 18:20:08 2016 -0400

----------------------------------------------------------------------
 .../jms/pool/PooledConnectionFactory.java       |  1 +
 .../jms/pool/PooledConnectionFactoryTest.java   | 27 ++++++++++++++++++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/0706fd0b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
index a75fb62..967f46e 100644
--- a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
+++ b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
@@ -301,6 +301,7 @@ public class PooledConnectionFactory implements ConnectionFactory, QueueConnecti
             try {
                 if (connectionsPool != null) {
                     connectionsPool.close();
+                    connectionsPool = null;
                 }
             } catch (Exception e) {
             }

http://git-wip-us.apache.org/repos/asf/activemq/blob/0706fd0b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
index 7cdf2b9..0be8108 100644
--- a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
+++ b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.jms.pool;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -123,6 +124,32 @@ public class PooledConnectionFactoryTest extends JmsPoolTestSupport {
     }
 
     @Test(timeout = 60000)
+    public void testFactoryStopStart() throws Exception {
+
+        ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory(
+            "vm://broker1?marshal=false&broker.persistent=false&broker.useJmx=false");
+        PooledConnectionFactory cf = new PooledConnectionFactory();
+        cf.setConnectionFactory(amq);
+        cf.setMaxConnections(1);
+
+        PooledConnection conn1 = (PooledConnection) cf.createConnection();
+
+        cf.stop();
+
+        assertNull(cf.createConnection());
+
+        cf.start();
+
+        PooledConnection conn2 = (PooledConnection) cf.createConnection();
+
+        assertNotSame(conn1.getConnection(), conn2.getConnection());
+
+        assertEquals(1, cf.getNumConnections());
+
+        cf.stop();
+    }
+
+    @Test(timeout = 60000)
     public void testConnectionsAreRotated() throws Exception {
 
         ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory(


Mime
View raw message