activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject activemq git commit: rework npe avoidance in vmtransport stop to resolve thread leakage test failure
Date Mon, 12 Jan 2015 02:56:56 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.10.x 9989f3a18 -> 0a37e85ac


rework npe avoidance in vmtransport stop to resolve thread leakage test failure

Conflicts:
	activemq-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java


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

Branch: refs/heads/activemq-5.10.x
Commit: 0a37e85ac247814d9e0343deb103822c734afb4a
Parents: 9989f3a
Author: gtully <gary.tully@gmail.com>
Authored: Mon Oct 13 22:24:02 2014 +0100
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Fri Jan 9 20:36:46 2015 -0500

----------------------------------------------------------------------
 .../activemq/transport/vm/VMTransport.java      | 26 +++++++++++---------
 .../transport/failover/AMQ1925Test.java         |  4 +--
 .../activemq/usecases/QueueBrowsingTest.java    |  4 ++-
 3 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/0a37e85a/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
b/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
index ef1b1e2..75bd6fe 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
@@ -171,7 +171,7 @@ public class VMTransport implements Transport, Task {
     public void stop() throws Exception {
         // Only need to do this once, all future oneway calls will now
         // fail as will any asnyc jobs in the task runner.
-        if (disposed.compareAndSet(false, true) && started.get()) {
+        if (disposed.compareAndSet(false, true)) {
 
             TaskRunner tr = taskRunner;
             LinkedBlockingQueue<Object> mq = this.messageQueue;
@@ -193,18 +193,20 @@ public class VMTransport implements Transport, Task {
                 tr = null;
             }
 
-            // let the peer know that we are disconnecting after attempting
-            // to cleanly shutdown the async tasks so that this is the last
-            // command it see's.
-            try {
-                peer.transportListener.onCommand(new ShutdownInfo());
-            } catch (Exception ignore) {
-            }
+            if (peer.transportListener != null) {
+                // let the peer know that we are disconnecting after attempting
+                // to cleanly shutdown the async tasks so that this is the last
+                // command it see's.
+                try {
+                    peer.transportListener.onCommand(new ShutdownInfo());
+                } catch (Exception ignore) {
+                }
 
-            // let any requests pending a response see an exception
-            try {
-                peer.transportListener.onException(new TransportDisposedIOException("peer
(" + this + ") stopped."));
-            } catch (Exception ignore) {
+                // let any requests pending a response see an exception
+                try {
+                    peer.transportListener.onException(new TransportDisposedIOException("peer
(" + this + ") stopped."));
+                } catch (Exception ignore) {
+                }
             }
 
             // shutdown task runner factory

http://git-wip-us.apache.org/repos/asf/activemq/blob/0a37e85a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
index ce78f7f..dfb5dfd 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
@@ -266,7 +266,7 @@ public class AMQ1925Test extends TestCase implements ExceptionListener
{
 
 		boolean restartDone = false;
 		for (int i = 0; i < MESSAGE_COUNT; i++) {
-			Message message = consumer.receive(500);
+			Message message = consumer.receive(5000);
 			assertNotNull(message);
 
 			if (i == 222 && !restartDone) {
@@ -307,7 +307,7 @@ public class AMQ1925Test extends TestCase implements ExceptionListener
{
 				.createQueue(QUEUE_NAME));
 
 		for (int i = 0; i < MESSAGE_COUNT; i++) {
-			Message message = consumer.receive(500);
+			Message message = consumer.receive(5000);
 			assertNotNull(message);
 
 			assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));

http://git-wip-us.apache.org/repos/asf/activemq/blob/0a37e85a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java
index 2c54455..29b6e72 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java
@@ -17,6 +17,8 @@
 package org.apache.activemq.usecases;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 
 import java.io.IOException;
 import java.net.URI;
@@ -209,6 +211,6 @@ public class QueueBrowsingTest {
         }
 
         browser.close();
-        assertEquals(maxPageSize + 2, received);
+        assertTrue("got at least maxPageSize", received >= maxPageSize);
     }
 }


Mime
View raw message