From 29b833fe8ed87141e4a5870fe3c2377f5107437f Mon Sep 17 00:00:00 2001 From: gtully Date: Thu, 26 May 2016 11:30:14 +0100 Subject: [PATCH] fix shadowing and ensure close of connection, ci... --- .../org/apache/activemq/JmsTransactionTestSupport.java | 5 ++++- .../test/java/org/apache/activemq/test/TestSupport.java | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java b/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java index 7f212cd24f..423f1eec03 100755 --- a/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java +++ b/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java @@ -49,7 +49,6 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M private static final int MESSAGE_COUNT = 5; private static final String MESSAGE_TEXT = "message"; - protected ConnectionFactory connectionFactory; protected Connection connection; protected Session session; protected MessageConsumer consumer; @@ -130,6 +129,10 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M try { session.close(); session = null; + } catch (Exception e) { + LOG.info("Caught exception while closing resources."); + } + try { connection.close(); connection = null; } catch (Exception e) { diff --git a/activemq-broker/src/test/java/org/apache/activemq/test/TestSupport.java b/activemq-broker/src/test/java/org/apache/activemq/test/TestSupport.java index a73bc408a2..6acb807b99 100755 --- a/activemq-broker/src/test/java/org/apache/activemq/test/TestSupport.java +++ b/activemq-broker/src/test/java/org/apache/activemq/test/TestSupport.java @@ -20,6 +20,7 @@ import java.io.File; import java.lang.reflect.Array; import javax.jms.Connection; +import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; @@ -42,7 +43,7 @@ import org.slf4j.LoggerFactory; public abstract class TestSupport extends TestCase { private static final Logger LOG = LoggerFactory.getLogger(TestSupport.class); - protected ActiveMQConnectionFactory connectionFactory; + protected ConnectionFactory connectionFactory; protected boolean topic = true; public TestSupport() { @@ -184,7 +185,7 @@ public abstract class TestSupport extends TestCase { * @return ActiveMQConnectionFactory * @throws Exception */ - protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { + protected ConnectionFactory createConnectionFactory() throws Exception { return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); } @@ -204,7 +205,7 @@ public abstract class TestSupport extends TestCase { * @return connectionFactory * @throws Exception */ - public ActiveMQConnectionFactory getConnectionFactory() throws Exception { + public ConnectionFactory getConnectionFactory() throws Exception { if (connectionFactory == null) { connectionFactory = createConnectionFactory(); assertTrue("Should have created a connection factory!", connectionFactory != null);