mirror of https://github.com/apache/activemq.git
resolve: https://issues.apache.org/jira/browse/AMQ-3033 - dangling ref to timer
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1049105 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3ddb71c65b
commit
ccd2e94f4e
|
@ -20,10 +20,12 @@ import java.net.URI;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.jms.Connection;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
import org.apache.activemq.bugs.embedded.ThreadExplorer;
|
||||||
import org.apache.activemq.network.NetworkConnector;
|
import org.apache.activemq.network.NetworkConnector;
|
||||||
|
|
||||||
public class VmTransportNetworkBrokerTest extends TestCase {
|
public class VmTransportNetworkBrokerTest extends TestCase {
|
||||||
|
@ -45,7 +47,8 @@ public class VmTransportNetworkBrokerTest extends TestCase {
|
||||||
broker.start();
|
broker.start();
|
||||||
|
|
||||||
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI));
|
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
|
// let it settle
|
||||||
TimeUnit.SECONDS.sleep(5);
|
TimeUnit.SECONDS.sleep(5);
|
||||||
|
@ -54,9 +57,31 @@ public class VmTransportNetworkBrokerTest extends TestCase {
|
||||||
TimeUnit.SECONDS.sleep(30);
|
TimeUnit.SECONDS.sleep(30);
|
||||||
int threadCountAfterSleep = Thread.activeCount();
|
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);
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class Journal {
|
||||||
private ReplicationTarget replicationTarget;
|
private ReplicationTarget replicationTarget;
|
||||||
protected boolean checksum;
|
protected boolean checksum;
|
||||||
protected boolean checkForCorruptionOnStartup;
|
protected boolean checkForCorruptionOnStartup;
|
||||||
private Timer timer = new Timer("KahaDB Scheduler", true);
|
private Timer timer;
|
||||||
|
|
||||||
|
|
||||||
public synchronized void start() throws IOException {
|
public synchronized void start() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue