File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
src/com/rabbitmq/client/impl
test/src/com/rabbitmq/client/test/functional Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ public class ChannelN extends AMQChannel implements com.rabbitmq.client.Channel
8383 /** Sequence number of next published message requiring confirmation.*/
8484 private long nextPublishSeqNo = 0L ;
8585
86+ private volatile boolean confirmSelected = false ;
87+
8688 /** The current default consumer, or null if there is none. */
8789 private volatile Consumer defaultConsumer = null ;
8890
@@ -175,6 +177,8 @@ public boolean waitForConfirms()
175177 /** {@inheritDoc} */
176178 public boolean waitForConfirms (long timeout )
177179 throws InterruptedException , TimeoutException {
180+ if (!confirmSelected )
181+ throw new IllegalStateException ("Confirms not selected" );
178182 long startTime = System .currentTimeMillis ();
179183 synchronized (unconfirmedSet ) {
180184 while (true ) {
@@ -1048,6 +1052,7 @@ public Tx.RollbackOk txRollback()
10481052 public Confirm .SelectOk confirmSelect ()
10491053 throws IOException
10501054 {
1055+ confirmSelected = true ;
10511056 if (nextPublishSeqNo == 0 ) nextPublishSeqNo = 1 ;
10521057 return (Confirm .SelectOk )
10531058 exnWrappingRpc (new Confirm .Select (false )).getMethod ();
Original file line number Diff line number Diff line change @@ -229,13 +229,16 @@ public void handleNack(long seqNo, boolean multiple) {
229229 }
230230 }
231231
232- public void testWaitForConfirmsNoOp ()
232+ public void testWaitForConfirmsWithoutConfirmSelected ()
233233 throws IOException , InterruptedException
234234 {
235235 channel = connection .createChannel ();
236236 // Don't enable Confirm mode
237237 publish ("" , "confirm-test" , true , false );
238- channel .waitForConfirmsOrDie (); // Nop
238+ try {
239+ channel .waitForConfirms ();
240+ fail ("waitForConfirms without confirms selected succeeded" );
241+ } catch (IllegalStateException _) {}
239242 }
240243
241244 public void testWaitForConfirmsException ()
You can’t perform that action at this time.
0 commit comments