diff --git a/src/test/java/com/rabbitmq/client/AbstractJsonRpcTest.java b/src/test/java/com/rabbitmq/client/AbstractJsonRpcTest.java index 6172a8f20..402b01bf1 100644 --- a/src/test/java/com/rabbitmq/client/AbstractJsonRpcTest.java +++ b/src/test/java/com/rabbitmq/client/AbstractJsonRpcTest.java @@ -68,8 +68,8 @@ public void tearDown() throws Exception { if (serverChannel != null) { serverChannel.queueDelete(queue); } - clientConnection.close(); - serverConnection.close(); + clientConnection.close(10_000); + serverConnection.close(10_000); } public interface RpcService { diff --git a/src/test/java/com/rabbitmq/client/test/AMQConnectionTest.java b/src/test/java/com/rabbitmq/client/test/AMQConnectionTest.java index a12a6d2a8..83ab6baad 100644 --- a/src/test/java/com/rabbitmq/client/test/AMQConnectionTest.java +++ b/src/test/java/com/rabbitmq/client/test/AMQConnectionTest.java @@ -167,30 +167,30 @@ public class AMQConnectionTest { String providedName = "event consumers connection"; Connection connection = factory.newConnection(providedName); assertEquals(providedName, connection.getClientProvidedName()); - connection.close(); + connection.close(10_000); List
addrs1 = Arrays.asList(new Address("127.0.0.1"), new Address("127.0.0.1", 5672)); connection = factory.newConnection(addrs1, providedName); assertEquals(providedName, connection.getClientProvidedName()); - connection.close(); + connection.close(10_000); Address[] addrs2 = {new Address("127.0.0.1"), new Address("127.0.0.1", 5672)}; connection = factory.newConnection(addrs2, providedName); assertEquals(providedName, connection.getClientProvidedName()); - connection.close(); + connection.close(10_000); ExecutorService xs = Executors.newSingleThreadExecutor(); connection = factory.newConnection(xs, providedName); assertEquals(providedName, connection.getClientProvidedName()); - connection.close(); + connection.close(10_000); connection = factory.newConnection(xs, addrs1, providedName); assertEquals(providedName, connection.getClientProvidedName()); - connection.close(); + connection.close(10_000); connection = factory.newConnection(xs, addrs2, providedName); assertEquals(providedName, connection.getClientProvidedName()); - connection.close(); + connection.close(10_000); } /** Mock frame handler to facilitate testing. */ diff --git a/src/test/java/com/rabbitmq/client/test/BlockedConnectionTest.java b/src/test/java/com/rabbitmq/client/test/BlockedConnectionTest.java index cbbdc5bf2..0a98be056 100644 --- a/src/test/java/com/rabbitmq/client/test/BlockedConnectionTest.java +++ b/src/test/java/com/rabbitmq/client/test/BlockedConnectionTest.java @@ -95,7 +95,7 @@ void shutdownListenerShouldBeCalledWhenChannelDies() throws Exception { if (blocked) { unblock(); } - c.close(); + c.close(10_000); } } } diff --git a/src/test/java/com/rabbitmq/client/test/BrokerTestCase.java b/src/test/java/com/rabbitmq/client/test/BrokerTestCase.java index 26fcffb0d..5ce0d1827 100644 --- a/src/test/java/com/rabbitmq/client/test/BrokerTestCase.java +++ b/src/test/java/com/rabbitmq/client/test/BrokerTestCase.java @@ -21,6 +21,8 @@ import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Map; @@ -33,6 +35,8 @@ public class BrokerTestCase { + private static final Logger LOGGER = LoggerFactory.getLogger(BrokerTestCase.class); + private String brokerVersion; protected volatile TestInfo testInfo; @@ -132,7 +136,11 @@ public void openConnection() public void closeConnection() throws IOException { if (connection != null) { - connection.abort(); + try { + connection.abort(10_000); + } catch (Exception e) { + LOGGER.warn("Error while closing connection: {}", e.getMessage()); + } connection = null; } } diff --git a/src/test/java/com/rabbitmq/client/test/ChannelNumberAllocationTests.java b/src/test/java/com/rabbitmq/client/test/ChannelNumberAllocationTests.java index 9e39e86b7..0674f9444 100644 --- a/src/test/java/com/rabbitmq/client/test/ChannelNumberAllocationTests.java +++ b/src/test/java/com/rabbitmq/client/test/ChannelNumberAllocationTests.java @@ -46,7 +46,7 @@ public int compare(Channel x, Channel y){ } @AfterEach public void tearDown() throws Exception{ - connection.close(); + connection.close(10_000); connection = null; } diff --git a/src/test/java/com/rabbitmq/client/test/ChannelRpcTimeoutIntegrationTest.java b/src/test/java/com/rabbitmq/client/test/ChannelRpcTimeoutIntegrationTest.java index 6ee506733..ccd43f663 100644 --- a/src/test/java/com/rabbitmq/client/test/ChannelRpcTimeoutIntegrationTest.java +++ b/src/test/java/com/rabbitmq/client/test/ChannelRpcTimeoutIntegrationTest.java @@ -55,7 +55,7 @@ public void tearDown() { Channel channel = connection.createChannel(); channel.queueDeclare(); } finally { - connection.close(); + connection.close(10_000); } } @@ -78,7 +78,7 @@ public void tearDown() { assertThat(e.getMethod()).isInstanceOf(AMQP.Queue.Declare.class); } } finally { - connection.close(); + connection.close(10_000); } } diff --git a/src/test/java/com/rabbitmq/client/test/CloseInMainLoop.java b/src/test/java/com/rabbitmq/client/test/CloseInMainLoop.java index c7787de5c..ea05018ae 100644 --- a/src/test/java/com/rabbitmq/client/test/CloseInMainLoop.java +++ b/src/test/java/com/rabbitmq/client/test/CloseInMainLoop.java @@ -93,7 +93,7 @@ public boolean processControlCommand(Command c) throws IOException{ @Test public void closeOKNormallyReceived() throws Exception{ SpecialConnection connection = new SpecialConnection(); - connection.close(); + connection.close(10_000); assertTrue(connection.hadValidShutdown()); } diff --git a/src/test/java/com/rabbitmq/client/test/DnsRecordIpAddressResolverTests.java b/src/test/java/com/rabbitmq/client/test/DnsRecordIpAddressResolverTests.java index c339bf34e..ff5c865ee 100644 --- a/src/test/java/com/rabbitmq/client/test/DnsRecordIpAddressResolverTests.java +++ b/src/test/java/com/rabbitmq/client/test/DnsRecordIpAddressResolverTests.java @@ -23,7 +23,7 @@ public class DnsRecordIpAddressResolverTests extends BrokerTestCase { try { connection.createChannel(); } finally { - connection.abort(); + connection.abort(10_000); } } @@ -34,7 +34,7 @@ public class DnsRecordIpAddressResolverTests extends BrokerTestCase { try { connection.createChannel(); } finally { - connection.abort(); + connection.abort(10_000); } } diff --git a/src/test/java/com/rabbitmq/client/test/NoAutoRecoveryWhenTcpWindowIsFullTest.java b/src/test/java/com/rabbitmq/client/test/NoAutoRecoveryWhenTcpWindowIsFullTest.java index 4c474a2b4..566df4429 100644 --- a/src/test/java/com/rabbitmq/client/test/NoAutoRecoveryWhenTcpWindowIsFullTest.java +++ b/src/test/java/com/rabbitmq/client/test/NoAutoRecoveryWhenTcpWindowIsFullTest.java @@ -155,7 +155,7 @@ public void handleRecoveryStarted(Recoverable recoverable) { private void closeConnectionIfOpen(Connection connection) throws IOException { if (connection.isOpen()) { - connection.close(); + connection.close(10_000); } } diff --git a/src/test/java/com/rabbitmq/client/test/QueueingConsumerTests.java b/src/test/java/com/rabbitmq/client/test/QueueingConsumerTests.java index be689b96f..5b06212be 100644 --- a/src/test/java/com/rabbitmq/client/test/QueueingConsumerTests.java +++ b/src/test/java/com/rabbitmq/client/test/QueueingConsumerTests.java @@ -61,7 +61,7 @@ public class QueueingConsumerTests extends BrokerTestCase{ }.start(); } - connection.close(); + connection.close(10_000); // Far longer than this could reasonably take assertTrue(latch.await(5, TimeUnit.SECONDS)); diff --git a/src/test/java/com/rabbitmq/client/test/SharedThreadPoolTest.java b/src/test/java/com/rabbitmq/client/test/SharedThreadPoolTest.java index 63a875b60..4deed1870 100644 --- a/src/test/java/com/rabbitmq/client/test/SharedThreadPoolTest.java +++ b/src/test/java/com/rabbitmq/client/test/SharedThreadPoolTest.java @@ -76,7 +76,7 @@ void close(ExecutorService executor) { void close(Connection connection) throws IOException { if (connection != null) { - connection.close(); + connection.close(10_000); } } } diff --git a/src/test/java/com/rabbitmq/client/test/TestUtils.java b/src/test/java/com/rabbitmq/client/test/TestUtils.java index 2deacc708..c9ff744b1 100644 --- a/src/test/java/com/rabbitmq/client/test/TestUtils.java +++ b/src/test/java/com/rabbitmq/client/test/TestUtils.java @@ -151,7 +151,7 @@ public static void waitAtMost(Duration timeout, CallableBooleanSupplier conditio public static void close(Connection connection) { if (connection != null) { try { - connection.close(); + connection.close(10_000); } catch (IOException e) { throw new RuntimeException(e); } @@ -160,7 +160,7 @@ public static void close(Connection connection) { public static void abort(Connection connection) { if (connection != null) { - connection.abort(); + connection.abort(10_000); } } diff --git a/src/test/java/com/rabbitmq/client/test/functional/ClusteredTestBase.java b/src/test/java/com/rabbitmq/client/test/functional/ClusteredTestBase.java index 08885f661..0b2a74c54 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/ClusteredTestBase.java +++ b/src/test/java/com/rabbitmq/client/test/functional/ClusteredTestBase.java @@ -68,7 +68,7 @@ public void openConnection() throws IOException, TimeoutException { if (clusteredConnection != null && !clustered(connection, clusteredConnection)) { - clusteredConnection.close(); + clusteredConnection.close(10_000); clusteredConnection = null; if (!nonClusteredWarningPrinted) { @@ -116,7 +116,7 @@ public void closeChannel() throws IOException { @Override public void closeConnection() throws IOException { if (clusteredConnection != null) { - clusteredConnection.abort(); + clusteredConnection.abort(10_000); clusteredConnection = null; alternateConnection = null; } diff --git a/src/test/java/com/rabbitmq/client/test/functional/ConnectionRecovery.java b/src/test/java/com/rabbitmq/client/test/functional/ConnectionRecovery.java index 573831783..0231e6805 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/ConnectionRecovery.java +++ b/src/test/java/com/rabbitmq/client/test/functional/ConnectionRecovery.java @@ -66,7 +66,7 @@ public class ConnectionRecovery extends BrokerTestCase { assertThat(c.isOpen()).isTrue(); assertThat(connectionName).isEqualTo(c.getClientProvidedName()); } finally { - c.abort(); + c.abort(10_000); } } @@ -85,7 +85,7 @@ public class ConnectionRecovery extends BrokerTestCase { TestUtils.closeAndWaitForRecovery(c); assertThat(c.isOpen()).isTrue(); } finally { - c.abort(); + c.abort(10_000); } } @@ -101,7 +101,7 @@ public class ConnectionRecovery extends BrokerTestCase { TestUtils.closeAndWaitForRecovery(c); assertThat(c.isOpen()).isTrue(); } finally { - c.abort(); + c.abort(10_000); } } @@ -125,7 +125,7 @@ public class ConnectionRecovery extends BrokerTestCase { } catch (java.io.IOException e) { // expected } finally { - c.abort(); + c.abort(10_000); } } @@ -163,7 +163,7 @@ public String getPassword() { assertThat(usernameRequested.get()).isGreaterThanOrEqualTo(2); assertThat(passwordRequested.get()).isEqualTo(2); } finally { - c.abort(); + c.abort(10_000); } } @@ -204,7 +204,7 @@ public void handleTopologyRecoveryStarted(Recoverable recoverable) { assertThat(events).element(1).isEqualTo("shutdown hook 2"); recoveryCanBeginLatch.await(5, TimeUnit.SECONDS); assertThat(events).element(2).isEqualTo("recovery start hook 1"); - connection.close(); + connection.close(10_000); wait(latch); } @@ -214,7 +214,7 @@ public void handleTopologyRecoveryStarted(Recoverable recoverable) { assertThat(connection.isOpen()).isTrue(); closeAndWaitForRecovery(); assertThat(connection.isOpen()).isTrue(); - connection.close(); + connection.close(10_000); wait(latch); } @@ -226,7 +226,7 @@ public void handleTopologyRecoveryStarted(Recoverable recoverable) { assertThat(connection.isOpen()).isTrue(); closeAndWaitForRecovery(); assertThat(connection.isOpen()).isTrue(); - connection.close(); + connection.close(10_000); wait(latch); } @@ -749,7 +749,7 @@ public void handleDelivery(String consumerTag, publishingChannel.basicPublish("", q, null, "msg".getBytes()); } wait(latch); - publishingConnection.abort(); + publishingConnection.abort(10_000); } @Test public void consumersAreRemovedFromConnectionWhenChannelIsClosed() throws Exception { @@ -780,7 +780,7 @@ public void handleDelivery(String consumerTag, channel2.close(); assertThat(connectionConsumers).isEmpty(); } finally { - connection.abort(); + connection.abort(10_000); } } @@ -794,7 +794,7 @@ public void handleDelivery(String consumerTag, TestUtils.closeAndWaitForRecovery((RecoverableConnection) testConnection); assertThat(testConnection.isOpen()).isTrue(); } finally { - testConnection.close(); + testConnection.close(10_000); } } @@ -862,7 +862,7 @@ public void handleDelivery(String consumerTag, Envelope envelope, BasicPropertie for (String x : exchanges) cleanupChannel.exchangeDelete(x); } finally { - testConnection.close(); + testConnection.close(10_000); } } diff --git a/src/test/java/com/rabbitmq/client/test/functional/ExchangeDeclare.java b/src/test/java/com/rabbitmq/client/test/functional/ExchangeDeclare.java index da5769b4b..dcef15c3e 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/ExchangeDeclare.java +++ b/src/test/java/com/rabbitmq/client/test/functional/ExchangeDeclare.java @@ -95,7 +95,7 @@ public void releaseResources() throws IOException { try { doTestExchangeDeclaredWithEnumerationEquivalent(c.createChannel()); } finally { - c.abort(); + c.abort(10_000); } } diff --git a/src/test/java/com/rabbitmq/client/test/functional/Metrics.java b/src/test/java/com/rabbitmq/client/test/functional/Metrics.java index a66bcb8f6..6c27fa3d0 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/Metrics.java +++ b/src/test/java/com/rabbitmq/client/test/functional/Metrics.java @@ -628,7 +628,7 @@ public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProp private void safeClose(Connection connection) { if(connection != null) { try { - connection.abort(); + connection.abort(10_000); } catch (Exception e) { // OK } diff --git a/src/test/java/com/rabbitmq/client/test/functional/MicrometerObservationCollectorMetrics.java b/src/test/java/com/rabbitmq/client/test/functional/MicrometerObservationCollectorMetrics.java index 17647c921..9e82bec96 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/MicrometerObservationCollectorMetrics.java +++ b/src/test/java/com/rabbitmq/client/test/functional/MicrometerObservationCollectorMetrics.java @@ -110,7 +110,7 @@ protected void releaseResources() throws IOException { private void safeClose(Connection connection) { if (connection != null) { try { - connection.abort(); + connection.abort(10_000); } catch (Exception e) { // OK } diff --git a/src/test/java/com/rabbitmq/client/test/functional/QueueExclusivity.java b/src/test/java/com/rabbitmq/client/test/functional/QueueExclusivity.java index ae6609e9c..9c70f31f9 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/QueueExclusivity.java +++ b/src/test/java/com/rabbitmq/client/test/functional/QueueExclusivity.java @@ -49,7 +49,7 @@ protected void createResources() throws IOException, TimeoutException { protected void releaseResources() throws IOException { if (altConnection != null && altConnection.isOpen()) { - altConnection.close(); + altConnection.close(10_000); } } diff --git a/src/test/java/com/rabbitmq/client/test/functional/SaslMechanisms.java b/src/test/java/com/rabbitmq/client/test/functional/SaslMechanisms.java index 4bc6b9ebd..411102954 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/SaslMechanisms.java +++ b/src/test/java/com/rabbitmq/client/test/functional/SaslMechanisms.java @@ -105,7 +105,7 @@ public void anonymousShouldSucceed() throws Exception { ConnectionFactory factory = TestUtils.connectionFactory(); factory.setSaslConfig(DefaultSaslConfig.ANONYMOUS); Connection connection = factory.newConnection(); - connection.close(); + connection.close(10_000); } public void connectionCloseAuthFailure(String username, String password) throws IOException, TimeoutException { @@ -113,7 +113,7 @@ public void connectionCloseAuthFailure(String username, String password) throws try { Connection conn = connectionWithoutCapabilities(username, password); fail("Expected PossibleAuthenticationFailureException " + failDetail); - conn.abort(); + conn.abort(10_000); } catch (PossibleAuthenticationFailureException paf) { if (paf instanceof AuthenticationFailureException) { fail("Not expecting AuthenticationFailureException " + failDetail); @@ -138,7 +138,7 @@ private void loginOk(String name, byte[][] responses) throws IOException, Timeou ConnectionFactory factory = TestUtils.connectionFactory(); factory.setSaslConfig(new Config(name, responses)); Connection connection = factory.newConnection(); - connection.close(); + connection.close(10_000); } private void loginBad(String name, byte[][] responses) throws IOException, TimeoutException { diff --git a/src/test/java/com/rabbitmq/client/test/functional/TopologyRecoveryFiltering.java b/src/test/java/com/rabbitmq/client/test/functional/TopologyRecoveryFiltering.java index 8edd432a6..b6919035f 100644 --- a/src/test/java/com/rabbitmq/client/test/functional/TopologyRecoveryFiltering.java +++ b/src/test/java/com/rabbitmq/client/test/functional/TopologyRecoveryFiltering.java @@ -75,7 +75,7 @@ protected void createResources() throws IOException, TimeoutException { @Override protected void releaseResources() throws IOException { super.releaseResources(); - c.close(); + c.close(10_000); deleteExchanges(exchangesToDelete); deleteQueues(queuesToDelete); } diff --git a/src/test/java/com/rabbitmq/client/test/server/DurableBindingLifecycle.java b/src/test/java/com/rabbitmq/client/test/server/DurableBindingLifecycle.java index dedd6eff8..4861ef79a 100644 --- a/src/test/java/com/rabbitmq/client/test/server/DurableBindingLifecycle.java +++ b/src/test/java/com/rabbitmq/client/test/server/DurableBindingLifecycle.java @@ -42,7 +42,7 @@ public class DurableBindingLifecycle extends BindingLifecycleBase { @Override protected void restart() throws IOException, TimeoutException { if (clusteredConnection != null) { - clusteredConnection.abort(); + clusteredConnection.abort(10_000); clusteredConnection = null; clusteredChannel = null; alternateConnection = null; diff --git a/src/test/java/com/rabbitmq/client/test/server/LoopbackUsers.java b/src/test/java/com/rabbitmq/client/test/server/LoopbackUsers.java index e81de3703..7664e2e03 100644 --- a/src/test/java/com/rabbitmq/client/test/server/LoopbackUsers.java +++ b/src/test/java/com/rabbitmq/client/test/server/LoopbackUsers.java @@ -83,7 +83,7 @@ private void assertGuestFail(String addr) throws IOException, TimeoutException { } private void succeedConnect(String name, String addr) throws IOException, TimeoutException { - getFactory(name, addr).newConnection().close(); + getFactory(name, addr).newConnection().close(10_000); } private void failConnect(String name, String addr) throws IOException, TimeoutException { diff --git a/src/test/java/com/rabbitmq/client/test/server/MemoryAlarms.java b/src/test/java/com/rabbitmq/client/test/server/MemoryAlarms.java index c2e0217a5..e607517a3 100644 --- a/src/test/java/com/rabbitmq/client/test/server/MemoryAlarms.java +++ b/src/test/java/com/rabbitmq/client/test/server/MemoryAlarms.java @@ -58,7 +58,7 @@ public void tearDown(TestInfo info) throws IOException, TimeoutException { channel2 = null; } if (connection2 != null) { - connection2.abort(); + connection2.abort(10_000); connection2 = null; } super.tearDown(info); diff --git a/src/test/java/com/rabbitmq/client/test/server/Permissions.java b/src/test/java/com/rabbitmq/client/test/server/Permissions.java index 44d0bb18d..313ad05fd 100644 --- a/src/test/java/com/rabbitmq/client/test/server/Permissions.java +++ b/src/test/java/com/rabbitmq/client/test/server/Permissions.java @@ -108,7 +108,7 @@ public void with(String name) throws IOException { adminCh.queueDelete(name); adminCh.exchangeDelete(name); }}); - adminCh.getConnection().abort(); + adminCh.getConnection().abort(10_000); } protected void withNames(WithName action)