You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/01/03 23:06:44 UTC
svn commit: r1428632 -
/activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionSessionCleanupTest.java
Author: tabish
Date: Thu Jan 3 22:06:43 2013
New Revision: 1428632
URL: http://svn.apache.org/viewvc?rev=1428632&view=rev
Log:
Add some defensive checks in cleanup method to avoid possible NPE
Modified:
activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionSessionCleanupTest.java
Modified: activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionSessionCleanupTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionSessionCleanupTest.java?rev=1428632&r1=1428631&r2=1428632&view=diff
==============================================================================
--- activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionSessionCleanupTest.java (original)
+++ activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionSessionCleanupTest.java Thu Jan 3 22:06:43 2013
@@ -67,6 +67,7 @@ public class PooledConnectionSessionClea
@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 PooledConnectionSessionClea
@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 PooledConnectionSessionClea
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;