Skip to content

Commit 5723bc1

Browse files
committed
fix logic bug in handling of multi-confirms
The code was assuming that there would be a contiguous sequence between the first pending confirm and the received confirm, which isn't the case since previous confirms can have punched holes into that sequence.
1 parent d27d9a7 commit 5723bc1

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ protected void setUp() throws IOException {
5858
channel.setAckListener(new AckListener() {
5959
public void handleAck(long seqNo,
6060
boolean multiple) {
61-
if (multiple) {
62-
Confirm.this.gotAckForMultiple(seqNo);
63-
} else {
64-
Confirm.this.gotAckFor(seqNo);
65-
}
61+
Confirm.this.handleAck(seqNo, multiple);
6662
}
6763
});
6864
channel.confirmSelect();
@@ -271,16 +267,15 @@ private void publish(String exchangeName, String queueName,
271267
"nop".getBytes());
272268
}
273269

274-
private void gotAckForMultiple(long msgSeqNo) {
275-
for (long i = ackSet.first(); i <= msgSeqNo; ++i)
276-
gotAckFor(i);
277-
}
278-
279-
private void gotAckFor(long msgSeqNo) {
270+
private void handleAck(long msgSeqNo, boolean multiple) {
280271
if (!ackSet.contains(msgSeqNo)) {
281272
fail("got duplicate ack: " + msgSeqNo);
282273
}
283-
ackSet.remove(msgSeqNo);
274+
if (multiple) {
275+
ackSet.headSet(msgSeqNo + 1).clear();
276+
} else {
277+
ackSet.remove(msgSeqNo);
278+
}
284279
}
285280

286281
private void basicRejectCommon(boolean requeue)

0 commit comments

Comments
 (0)