You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2010/12/14 15:27:59 UTC
svn commit: r1049105 - in /activemq/trunk:
activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
kahadb/src/main/java/org/apache/kahadb/journal/Journal.java
Author: gtully
Date: Tue Dec 14 14:27:59 2010
New Revision: 1049105
URL: http://svn.apache.org/viewvc?rev=1049105&view=rev
Log:
resolve: https://issues.apache.org/jira/browse/AMQ-3033 - dangling ref to timer
Modified:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java
Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java?rev=1049105&r1=1049104&r2=1049105&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java Tue Dec 14 14:27:59 2010
@@ -20,10 +20,12 @@ import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import javax.jms.Connection;
import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.bugs.embedded.ThreadExplorer;
import org.apache.activemq.network.NetworkConnector;
public class VmTransportNetworkBrokerTest extends TestCase {
@@ -45,7 +47,8 @@ public class VmTransportNetworkBrokerTes
broker.start();
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI));
- cf.createConnection("system", "manager").start();
+ Connection connection = cf.createConnection("system", "manager");
+ connection.start();
// let it settle
TimeUnit.SECONDS.sleep(5);
@@ -54,9 +57,31 @@ public class VmTransportNetworkBrokerTes
TimeUnit.SECONDS.sleep(30);
int threadCountAfterSleep = Thread.activeCount();
- assertTrue("Threads are leaking, threadCount=" + threadCount + " threadCountAfterSleep=" + threadCountAfterSleep,
+ assertTrue("Threads are leaking: " + ThreadExplorer.show("active sleep") + ", threadCount=" + threadCount + " threadCountAfterSleep=" + threadCountAfterSleep,
threadCountAfterSleep < threadCount + 8);
-
- broker.stop();
+
+ connection.stop();
+ broker.stop();
+ broker.waitUntilStopped();
+
+ }
+
+ public void testNoDanglingThreadsAfterStop() throws Exception {
+
+ int threadCount = Thread.activeCount();
+ BrokerService broker = new BrokerService();
+ broker.setSchedulerSupport(true);
+ broker.setDedicatedTaskRunner(true);
+ broker.setPersistent(false);
+ broker.addConnector("tcp://localhost:61616");
+ broker.start();
+ broker.stop();
+ broker.waitUntilStopped();
+
+ int threadCountAfterStop = Thread.activeCount();
+ assertTrue("Threads are leaking: " + ThreadExplorer.show("active afer stop") + ". threadCount=" + threadCount + " threadCountAfterStop=" + threadCountAfterStop,
+ threadCountAfterStop == threadCount);
+
}
+
}
Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java?rev=1049105&r1=1049104&r2=1049105&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/journal/Journal.java Tue Dec 14 14:27:59 2010
@@ -117,7 +117,7 @@ public class Journal {
private ReplicationTarget replicationTarget;
protected boolean checksum;
protected boolean checkForCorruptionOnStartup;
- private Timer timer = new Timer("KahaDB Scheduler", true);
+ private Timer timer;
public synchronized void start() throws IOException {