|
45 | 45 | */ |
46 | 46 | public class TopologyRecoveryRetry extends BrokerTestCase { |
47 | 47 |
|
48 | | - private Consumer<Integer> backoffConsumer; |
| 48 | + private volatile Consumer<Integer> backoffConsumer; |
49 | 49 |
|
50 | 50 | @After |
51 | 51 | public void cleanup() { |
@@ -105,12 +105,14 @@ public void handleRecovery(Recoverable recoverable) { |
105 | 105 | // it should fail once more because queue is gone, and then succeed |
106 | 106 | final CountDownLatch backoffLatch = new CountDownLatch(1); |
107 | 107 | 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 | + } |
114 | 116 | } |
115 | 117 | backoffLatch.countDown(); |
116 | 118 | }; |
@@ -166,12 +168,14 @@ public void handleRecovery(Recoverable recoverable) { |
166 | 168 | // it should fail once more because queue is gone, and then succeed |
167 | 169 | final CountDownLatch backoffLatch = new CountDownLatch(1); |
168 | 170 | 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 | + } |
175 | 179 | } |
176 | 180 | backoffLatch.countDown(); |
177 | 181 | }; |
|
0 commit comments