activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1296396 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/TransportConnection.java test/java/org/apache/activemq/bugs/DurableConsumerTest.java
Date Fri, 02 Mar 2012 19:15:46 GMT
Author: gtully
Date: Fri Mar  2 19:15:45 2012
New Revision: 1296396

URL: http://svn.apache.org/viewvc?rev=1296396&view=rev
Log:
ensure broker stop ocurrs after subs connected and add defensive check to close identified
by one failure scenario

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java?rev=1296396&r1=1296395&r2=1296396&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Fri Mar  2 19:15:45 2012
@@ -964,7 +964,10 @@ public class TransportConnection impleme
             // so that in progress operations can notice and unblock.
             List<TransportConnectionState> connectionStates = listConnectionStates();
             for (TransportConnectionState cs : connectionStates) {
-                cs.getContext().getStopping().set(true);
+                ConnectionContext connectionContext = cs.getContext();
+                if (connectionContext != null) {
+                    connectionContext.getStopping().set(true);
+                }
             }
             try {
                 DefaultThreadPools.getDefaultTaskRunnerFactory().execute(new Runnable() {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java?rev=1296396&r1=1296395&r2=1296396&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java
Fri Mar  2 19:15:45 2012
@@ -172,8 +172,9 @@ public class DurableConsumerTest extends
         
         Thread publisherThread = new Thread(new MessagePublisher());
         publisherThread.start();
-        final List<SimpleTopicSubscriber> list = new ArrayList<SimpleTopicSubscriber>();
-        for (int i = 0; i < 100; i++) {
+        final int numSubs = 100;
+        final List<SimpleTopicSubscriber> list = new ArrayList<SimpleTopicSubscriber>(numSubs);
+        for (int i = 0; i < numSubs; i++) {
             
             final int id = i;
             Thread thread = new Thread(new Runnable(){
@@ -185,8 +186,14 @@ public class DurableConsumerTest extends
             thread.start();
             
         }
-        
-        Thread.sleep(5000);
+
+        Wait.waitFor(new Wait.Condition(){
+            @Override
+            public boolean isSatisified() throws Exception {
+                return numSubs == list.size();
+            }
+        });
+
         broker.stop();
         broker = createBroker(false);
         configurePersistence(broker);
@@ -195,7 +202,7 @@ public class DurableConsumerTest extends
         for (SimpleTopicSubscriber s:list) {
             s.closeConnection();
         }
-        assertEquals(0, exceptions.size());
+        assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
     }
     
     // makes heavy use of threads and can demonstrate https://issues.apache.org/activemq/browse/AMQ-2028



Mime
View raw message