Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/java/com/rabbitmq/client/AbstractJsonRpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/rabbitmq/client/test/AMQConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Address> 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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void shutdownListenerShouldBeCalledWhenChannelDies() throws Exception {
if (blocked) {
unblock();
}
c.close();
c.close(10_000);
}
}
}
10 changes: 9 additions & 1 deletion src/test/java/com/rabbitmq/client/test/BrokerTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +35,8 @@

public class BrokerTestCase {

private static final Logger LOGGER = LoggerFactory.getLogger(BrokerTestCase.class);

private String brokerVersion;

protected volatile TestInfo testInfo;
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void tearDown() {
Channel channel = connection.createChannel();
channel.queueDeclare();
} finally {
connection.close();
connection.close(10_000);
}

}
Expand All @@ -78,7 +78,7 @@ public void tearDown() {
assertThat(e.getMethod()).isInstanceOf(AMQP.Queue.Declare.class);
}
} finally {
connection.close();
connection.close(10_000);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class DnsRecordIpAddressResolverTests extends BrokerTestCase {
try {
connection.createChannel();
} finally {
connection.abort();
connection.abort(10_000);
}
}

Expand All @@ -34,7 +34,7 @@ public class DnsRecordIpAddressResolverTests extends BrokerTestCase {
try {
connection.createChannel();
} finally {
connection.abort();
connection.abort(10_000);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void close(ExecutorService executor) {

void close(Connection connection) throws IOException {
if (connection != null) {
connection.close();
connection.close(10_000);
}
}
}
4 changes: 2 additions & 2 deletions src/test/java/com/rabbitmq/client/test/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -85,7 +85,7 @@ public class ConnectionRecovery extends BrokerTestCase {
TestUtils.closeAndWaitForRecovery(c);
assertThat(c.isOpen()).isTrue();
} finally {
c.abort();
c.abort(10_000);
}

}
Expand All @@ -101,7 +101,7 @@ public class ConnectionRecovery extends BrokerTestCase {
TestUtils.closeAndWaitForRecovery(c);
assertThat(c.isOpen()).isTrue();
} finally {
c.abort();
c.abort(10_000);
}
}

Expand All @@ -125,7 +125,7 @@ public class ConnectionRecovery extends BrokerTestCase {
} catch (java.io.IOException e) {
// expected
} finally {
c.abort();
c.abort(10_000);
}
}

Expand Down Expand Up @@ -163,7 +163,7 @@ public String getPassword() {
assertThat(usernameRequested.get()).isGreaterThanOrEqualTo(2);
assertThat(passwordRequested.get()).isEqualTo(2);
} finally {
c.abort();
c.abort(10_000);
}
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -780,7 +780,7 @@ public void handleDelivery(String consumerTag,
channel2.close();
assertThat(connectionConsumers).isEmpty();
} finally {
connection.abort();
connection.abort(10_000);
}
}

Expand All @@ -794,7 +794,7 @@ public void handleDelivery(String consumerTag,
TestUtils.closeAndWaitForRecovery((RecoverableConnection) testConnection);
assertThat(testConnection.isOpen()).isTrue();
} finally {
testConnection.close();
testConnection.close(10_000);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void releaseResources() throws IOException {
try {
doTestExchangeDeclaredWithEnumerationEquivalent(c.createChannel());
} finally {
c.abort();
c.abort(10_000);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ 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 {
String failDetail = "for username " + username + " and password " + password;
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);
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading