diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java b/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java index 37a74f9a1d..5f7216a437 100755 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java @@ -238,4 +238,11 @@ public abstract class TestSupport extends CombinationTestSupport { assertFalse("Base directory cannot contain spaces.", new File(System.getProperty("basedir", ".")).getAbsoluteFile().toString().contains(" ")); } + public void safeCloseConnection(Connection c) { + if (c != null) { + try { + c.close(); + } catch (JMSException ignored) {} + } + } } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.java index 5d8b62ec81..2d840ab7c5 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/RedeliveryRestartWithExceptionTest.java @@ -119,7 +119,7 @@ public class RedeliveryRestartWithExceptionTest extends TestSupport { assertNotNull("Expecting an exception when updateMessage fails", expectedException); consumer.close(); - connection.close(); + safeCloseConnection(connection); restartBroker(); @@ -187,7 +187,7 @@ public class RedeliveryRestartWithExceptionTest extends TestSupport { assertNotNull("Expecting an exception when updateMessage fails", expectedException); consumer.close(); - connection.close(); + safeCloseConnection(connection); connection = (ActiveMQConnection) connectionFactory.createConnection(); connection.start();