activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [11/16] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5086 - init of broker got dropped after mutex wait - testWaitFor was failing
Date Tue, 16 Dec 2014 22:09:59 GMT
https://issues.apache.org/jira/browse/AMQ-5086 - init of broker got dropped after mutex wait
- testWaitFor was failing


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

Branch: refs/heads/activemq-5.10.x
Commit: db669e44d852aa1ed3d6822c07bb92415a3f807f
Parents: 00426a9
Author: gtully <gary.tully@gmail.com>
Authored: Mon Jul 14 16:49:03 2014 +0100
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Mon Dec 15 19:36:59 2014 -0500

----------------------------------------------------------------------
 .../transport/vm/VMTransportFactory.java        | 21 ++++++++++++++++----
 .../transport/vm/VMTransportWaitForTest.java    |  4 ++--
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/db669e44/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
b/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
index e88faaf..40caa81 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
@@ -184,12 +184,25 @@ public class VMTransportFactory extends TransportFactory {
                 final long expiry = System.currentTimeMillis() + waitForStart;
                 while ((broker == null || !broker.isStarted()) && expiry > System.currentTimeMillis())
{
                     long timeout = Math.max(0, expiry - System.currentTimeMillis());
-                    try {
+                    if (broker == null) {
+                        try {
+                            LOG.debug("waiting for broker named: " + brokerName + " to enter
registry");
+                            registry.getRegistryMutext().wait(timeout);
+                            broker = registry.lookup(brokerName);
+                        } catch (InterruptedException ignored) {
+                        }
+                    }
+                    if (broker != null && !broker.isStarted()) {
                         LOG.debug("waiting for broker named: " + brokerName + " to start");
-                        registry.getRegistryMutext().wait(timeout);
-                    } catch (InterruptedException ignored) {
+                        timeout = Math.max(0, expiry - System.currentTimeMillis());
+                        // Wait for however long we have left for broker to be started, if
+                        // it doesn't get started we need to clear broker so it doesn't get
+                        // returned.  A null return should throw an exception.
+                        if (!broker.waitUntilStarted(timeout)) {
+                            broker = null;
+                            break;
+                        }
                     }
-                    broker = registry.lookup(brokerName);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/activemq/blob/db669e44/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
index faa93e4..080d04d 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
@@ -52,7 +52,7 @@ public class VMTransportWaitForTest {
 
         // spawn a thread that will wait for an embedded broker to start via
         // vm://..
-        Thread t = new Thread() {
+        Thread t = new Thread("ClientConnectionThread") {
             @Override
             public void run() {
                 try {
@@ -74,7 +74,7 @@ public class VMTransportWaitForTest {
         BrokerService broker = new BrokerService();
         broker.setPersistent(false);
         broker.start();
-        assertTrue("has got connection", gotConnection.await(400, TimeUnit.MILLISECONDS));
+        assertTrue("has got connection", gotConnection.await(5, TimeUnit.SECONDS));
         broker.stop();
     }
 }


Mime
View raw message