Skip to content

Commit b52c708

Browse files
author
Steve Powell
committed
Remove volatile on monitor protected vars;
Move testPersistentMandatory() to front of Confirm test-suite; Make confirmTest and publish methods private in Confirm test-suite; Move confirm test-stuie to front of FunctionalTests suite list.
1 parent 3e41a36 commit b52c708

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ public class ChannelN extends AMQChannel implements com.rabbitmq.client.Channel
8888
/** Set of currently unconfirmed messages (i.e. messages that have
8989
* not been ack'd or nack'd by the server yet.
9090
* Used as monitor and protects nextPublishSeqNo and onlyAcksReceived. */
91-
private volatile SortedSet<Long> unconfirmedSet =
91+
private SortedSet<Long> unconfirmedSet =
9292
Collections.synchronizedSortedSet(new TreeSet<Long>());
9393
/** Sequence number of next published message requiring confirmation.
9494
* 0 means no confirmations. */
95-
private volatile long nextPublishSeqNo = 0L;
95+
private long nextPublishSeqNo = 0L;
9696
/** Whether any nacks have been received since the last
9797
* waitForConfirms(). */
98-
private volatile boolean noNacksReceived = true;
98+
private boolean noNacksReceived = true;
9999

100100
/**
101101
* Construct a new channel on the given connection with the given
@@ -1036,7 +1036,7 @@ protected void handleAckNack(long seqNo, boolean multiple, boolean nack) {
10361036
} else {
10371037
unconfirmedSet.remove(seqNo);
10381038
}
1039-
noNacksReceived = noNacksReceived && !nack;
1039+
noNacksReceived &= !nack;
10401040
if (unconfirmedSet.isEmpty())
10411041
unconfirmedSet.notifyAll();
10421042
}

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ private void declareBindQueue(String queueName, boolean durable)
7474
channel.queueBind(queueName, "amq.direct", "confirm-multiple-queues");
7575
}
7676

77+
public void testPersistentMandatory()
78+
throws Exception
79+
{
80+
declareConsumeQueue("confirm-test", true);
81+
confirmTest("", "confirm-test", true, true, false);
82+
}
83+
7784
public void testTransient()
7885
throws Exception
7986
{
@@ -109,13 +116,6 @@ public void testPersistentImmediateNoConsumer()
109116
confirmTest("", "confirm-test-noconsumer", true, false, true);
110117
}
111118

112-
public void testPersistentMandatory()
113-
throws Exception
114-
{
115-
declareConsumeQueue("confirm-test", true);
116-
confirmTest("", "confirm-test", true, true, false);
117-
}
118-
119119
public void testPersistentMandatoryReturn()
120120
throws Exception
121121
{
@@ -309,9 +309,9 @@ public void testWaitForConfirmsException()
309309
}
310310

311311
/* Publish NUM_MESSAGES messages and wait for confirmations. */
312-
public void confirmTest(String exchange, String queueName,
313-
boolean persistent, boolean mandatory,
314-
boolean immediate)
312+
private void confirmTest(String exchange, String queueName,
313+
boolean persistent, boolean mandatory,
314+
boolean immediate)
315315
throws Exception
316316
{
317317
publishN(exchange, queueName, persistent, mandatory, immediate);
@@ -342,10 +342,11 @@ private void basicRejectCommon(String queueName, boolean requeue)
342342
}
343343
}
344344

345-
protected void publish(String exchangeName, String queueName,
345+
private void publish(String exchangeName, String queueName,
346346
boolean persistent, boolean mandatory,
347347
boolean immediate)
348-
throws Exception {
348+
throws Exception
349+
{
349350
channel.basicPublish(exchangeName, queueName, mandatory, immediate,
350351
persistent ? MessageProperties.PERSISTENT_BASIC
351352
: MessageProperties.BASIC,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
public class FunctionalTests extends TestCase {
2525
public static TestSuite suite() {
2626
TestSuite suite = new TestSuite("functional");
27+
suite.addTestSuite(Confirm.class);
2728
suite.addTestSuite(ConnectionOpen.class);
2829
suite.addTestSuite(Heartbeat.class);
2930
suite.addTestSuite(Tables.class);
@@ -52,7 +53,6 @@ public static TestSuite suite() {
5253
suite.addTestSuite(InvalidAcksTx.class);
5354
suite.addTestSuite(DefaultExchange.class);
5455
suite.addTestSuite(UnbindAutoDeleteExchange.class);
55-
suite.addTestSuite(Confirm.class);
5656
suite.addTestSuite(ConsumerCancelNotificiation.class);
5757
suite.addTestSuite(UnexpectedFrames.class);
5858
suite.addTestSuite(PerQueueTTL.class);

0 commit comments

Comments
 (0)