Skip to content

Commit 6aea5b2

Browse files
committed
only drop on 1st retry
1 parent b1782f0 commit 6aea5b2

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/test/java/com/rabbitmq/client/test/functional/TopologyRecoveryRetry.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*/
4646
public class TopologyRecoveryRetry extends BrokerTestCase {
4747

48-
private Consumer<Integer> backoffConsumer;
48+
private volatile Consumer<Integer> backoffConsumer;
4949

5050
@After
5151
public void cleanup() {
@@ -105,12 +105,14 @@ public void handleRecovery(Recoverable recoverable) {
105105
// it should fail once more because queue is gone, and then succeed
106106
final CountDownLatch backoffLatch = new CountDownLatch(1);
107107
backoffConsumer = attempt -> {
108-
binding2.destination(queue);
109-
try {
110-
Host.rabbitmqctl("delete_queue " + queue);
111-
Thread.sleep(2000);
112-
} catch (Exception e) {
113-
e.printStackTrace();
108+
if (attempt == 1) {
109+
binding2.destination(queue);
110+
try {
111+
Host.rabbitmqctl("delete_queue " + queue);
112+
Thread.sleep(2000);
113+
} catch (Exception e) {
114+
e.printStackTrace();
115+
}
114116
}
115117
backoffLatch.countDown();
116118
};
@@ -166,12 +168,14 @@ public void handleRecovery(Recoverable recoverable) {
166168
// it should fail once more because queue is gone, and then succeed
167169
final CountDownLatch backoffLatch = new CountDownLatch(1);
168170
backoffConsumer = attempt -> {
169-
consumer.setQueue(queue);
170-
try {
171-
Host.rabbitmqctl("delete_queue " + queue);
172-
Thread.sleep(2000);
173-
} catch (Exception e) {
174-
e.printStackTrace();
171+
if (attempt == 1) {
172+
consumer.setQueue(queue);
173+
try {
174+
Host.rabbitmqctl("delete_queue " + queue);
175+
Thread.sleep(2000);
176+
} catch (Exception e) {
177+
e.printStackTrace();
178+
}
175179
}
176180
backoffLatch.countDown();
177181
};

0 commit comments

Comments
 (0)