Add some defensive checks in cleanup method to avoid possible NPE

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1428632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-01-03 22:06:43 +00:00
parent 5ddc7d65c3
commit 7a7d55180e
1 changed files with 19 additions and 6 deletions

View File

@ -67,6 +67,7 @@ public class PooledConnectionSessionCleanupTest {
@Before
public void prepTest() throws java.lang.Exception {
service = new BrokerService();
service.setBrokerName("PooledConnectionSessionCleanupTestBroker");
service.setUseJmx(true);
service.setPersistent(false);
service.setSchedulerSupport(false);
@ -97,23 +98,35 @@ public class PooledConnectionSessionCleanupTest {
@After
public void cleanupTest() throws java.lang.Exception {
try {
pooledConn1.close();
if (pooledConn1 != null) {
pooledConn1.close();
}
} catch (JMSException jms_exc) {
}
try {
pooledConn2.close();
if (pooledConn2 != null) {
pooledConn2.close();
}
} catch (JMSException jms_exc) {
}
try {
directConn1.close();
if (directConn1 != null) {
directConn1.close();
}
} catch (JMSException jms_exc) {
}
try {
directConn2.close();
if (directConn2 != null) {
directConn2.close();
}
} catch (JMSException jms_exc) {
}
try {
service.stop();
if (service != null) {
service.stop();
service.waitUntilStopped();
service = null;
}
} catch (JMSException jms_exc) {
}
}
@ -131,7 +144,7 @@ public class PooledConnectionSessionCleanupTest {
private QueueViewMBean getProxyToQueue(String name) throws MalformedObjectNameException, JMSException {
ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq"
+ ":destinationType=Queue,destinationName=" + name
+ ",type=Broker,brokerName=localhost");
+ ",type=Broker,brokerName=" + service.getBrokerName());
QueueViewMBean proxy = (QueueViewMBean) service.getManagementContext()
.newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
return proxy;