Skip to content

Commit a642549

Browse files
author
Rob Harrop
committed
Some cosmetic tweaks, and reintroduced volatile variable to ensure safe reference visibility
1 parent 9db2f2c commit a642549

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class Confirm extends BrokerTestCase
4949
{
5050
final static int NUM_MESSAGES = 1000;
5151
private static final String TTL_ARG = "x-message-ttl";
52-
private SortedSet<Long> ackSet;
52+
private volatile SortedSet<Long> ackSet;
5353

5454
@Override
5555
protected void setUp() throws IOException {
@@ -67,20 +67,28 @@ public void handleAck(long seqNo,
6767
});
6868
channel.confirmSelect(true);
6969
channel.queueDeclare("confirm-test", true, true, false, null);
70-
channel.basicConsume("confirm-test", true, new DefaultConsumer(channel));
71-
channel.queueDeclare("confirm-test-nondurable", false, true, false, null);
70+
channel.basicConsume("confirm-test", true,
71+
new DefaultConsumer(channel));
72+
channel.queueDeclare("confirm-test-nondurable", false, true,
73+
false, null);
7274
channel.basicConsume("confirm-test-nondurable", true,
7375
new DefaultConsumer(channel));
74-
channel.queueDeclare("confirm-test-noconsumer", true, true, false, null);
76+
channel.queueDeclare("confirm-test-noconsumer", true,
77+
true, false, null);
7578
channel.queueDeclare("confirm-test-2", true, true, false, null);
76-
channel.basicConsume("confirm-test-2", true, new DefaultConsumer(channel));
77-
Map<String, Object> argMap = Collections.singletonMap(TTL_ARG, (Object)1);
79+
channel.basicConsume("confirm-test-2", true,
80+
new DefaultConsumer(channel));
81+
Map<String, Object> argMap =
82+
Collections.singletonMap(TTL_ARG, (Object)1);
7883
channel.queueDeclare("confirm-ttl", true, true, false, argMap);
79-
channel.queueBind("confirm-test", "amq.direct", "confirm-multiple-queues");
80-
channel.queueBind("confirm-test-2", "amq.direct", "confirm-multiple-queues");
84+
channel.queueBind("confirm-test", "amq.direct",
85+
"confirm-multiple-queues");
86+
channel.queueBind("confirm-test-2", "amq.direct",
87+
"confirm-multiple-queues");
8188
}
8289

83-
public void testConfirmTransient() throws IOException, InterruptedException {
90+
public void testConfirmTransient()
91+
throws IOException, InterruptedException {
8492
confirmTest("", "confirm-test", false, false, false);
8593
}
8694

@@ -123,7 +131,8 @@ public void testConfirmPersistentMandatoryReturn()
123131
public void testConfirmMultipleQueues()
124132
throws IOException, InterruptedException
125133
{
126-
confirmTest("amq.direct", "confirm-multiple-queues", true, false, false);
134+
confirmTest("amq.direct", "confirm-multiple-queues",
135+
true, false, false);
127136
}
128137

129138
/* For testConfirmQueueDelete and testConfirmQueuePurge to be
@@ -187,7 +196,8 @@ public void testConfirmBasicRecover()
187196
publishN("", "confirm-test-noconsumer", true, false, false);
188197

189198
for (long i = 0; i < NUM_MESSAGES; i++) {
190-
GetResponse resp = channel.basicGet("confirm-test-noconsumer", false);
199+
GetResponse resp =
200+
channel.basicGet("confirm-test-noconsumer", false);
191201
long dtag = resp.getEnvelope().getDeliveryTag();
192202
// not acking
193203
}
@@ -287,7 +297,8 @@ private void basicRejectCommon(boolean requeue)
287297
publishN("", "confirm-test-noconsumer", true, false, false);
288298

289299
for (long i = 0; i < NUM_MESSAGES; i++) {
290-
GetResponse resp = channel.basicGet("confirm-test-noconsumer", false);
300+
GetResponse resp =
301+
channel.basicGet("confirm-test-noconsumer", false);
291302
long dtag = resp.getEnvelope().getDeliveryTag();
292303
channel.basicReject(dtag, requeue);
293304
}

0 commit comments

Comments
 (0)