@@ -121,10 +121,8 @@ public ChannelN(AMQConnection connection, int channelNumber,
121121 * @throws IOException if any problem is encountered
122122 */
123123 public void open () throws IOException {
124- // wait for the Channel.OpenOk response, then ignore it
125- Channel .OpenOk openOk =
126- (Channel .OpenOk ) exnWrappingRpc (new Channel .Open (UNSPECIFIED_OUT_OF_BAND )).getMethod ();
127- Utility .use (openOk );
124+ // wait for the Channel.OpenOk response, and ignore it
125+ exnWrappingRpc (new Channel .Open (UNSPECIFIED_OUT_OF_BAND ));
128126 }
129127
130128 public void addReturnListener (ReturnListener listener ) {
@@ -267,7 +265,7 @@ private CountDownLatch broadcastShutdownSignal(ShutdownSignalException signal) {
267265 }
268266 }
269267
270- public CountDownLatch getShutdownLatch () {
268+ CountDownLatch getShutdownLatch () {
271269 return this .finishedShutdownFlag ;
272270 }
273271
@@ -421,7 +419,7 @@ private void callReturnListeners(Command command, Basic.Return basicReturn) {
421419 }
422420 }
423421
424- private void callFlowListeners (Command command , Channel .Flow channelFlow ) {
422+ private void callFlowListeners (@ SuppressWarnings ( "unused" ) Command command , Channel .Flow channelFlow ) {
425423 try {
426424 for (FlowListener l : this .flowListeners ) {
427425 l .handleFlow (channelFlow .getActive ());
@@ -431,7 +429,7 @@ private void callFlowListeners(Command command, Channel.Flow channelFlow) {
431429 }
432430 }
433431
434- private void callConfirmListeners (Command command , Basic .Ack ack ) {
432+ private void callConfirmListeners (@ SuppressWarnings ( "unused" ) Command command , Basic .Ack ack ) {
435433 try {
436434 for (ConfirmListener l : this .confirmListeners ) {
437435 l .handleAck (ack .getDeliveryTag (), ack .getMultiple ());
@@ -441,7 +439,7 @@ private void callConfirmListeners(Command command, Basic.Ack ack) {
441439 }
442440 }
443441
444- private void callConfirmListeners (Command command , Basic .Nack nack ) {
442+ private void callConfirmListeners (@ SuppressWarnings ( "unused" ) Command command , Basic .Nack nack ) {
445443 try {
446444 for (ConfirmListener l : this .confirmListeners ) {
447445 l .handleNack (nack .getDeliveryTag (), nack .getMultiple ());
@@ -496,10 +494,17 @@ public void abort(int closeCode, String closeMessage)
496494 close (closeCode , closeMessage , true , null , true );
497495 }
498496
497+ // TODO: method should be private
499498 /**
500499 * Protected API - Close channel with code and message, indicating
501500 * the source of the closure and a causing exception (null if
502501 * none).
502+ * @param closeCode the close code (See under "Reply Codes" in the AMQP specification)
503+ * @param closeMessage a message indicating the reason for closing the connection
504+ * @param initiatedByApplication true if this comes from an API call, false otherwise
505+ * @param cause exception triggering close
506+ * @param abort true if we should close and ignore errors
507+ * @throws IOException if an error is encountered
503508 */
504509 public void close (int closeCode ,
505510 String closeMessage ,
@@ -941,23 +946,22 @@ public String transformReply(AMQCommand replyCommand) {
941946 public void basicCancel (final String consumerTag )
942947 throws IOException
943948 {
949+ final Consumer originalConsumer = _consumers .get (consumerTag );
950+ if (originalConsumer == null )
951+ throw new IOException ("Unknown consumerTag" );
944952 BlockingRpcContinuation <Consumer > k = new BlockingRpcContinuation <Consumer >() {
945953 public Consumer transformReply (AMQCommand replyCommand ) {
946- Basic .CancelOk dummy = (Basic .CancelOk ) replyCommand .getMethod ();
947- Utility .use (dummy );
948- Consumer callback = _consumers .remove (consumerTag );
949- // We need to call back inside the connection thread
950- // in order avoid races with 'deliver' commands
951- dispatcher .handleCancelOk (callback , consumerTag );
952- return callback ;
954+ replyCommand .getMethod ();
955+ _consumers .remove (consumerTag ); //may already have been removed
956+ dispatcher .handleCancelOk (originalConsumer , consumerTag );
957+ return originalConsumer ;
953958 }
954959 };
955960
956961 rpc (new Basic .Cancel (consumerTag , false ), k );
957962
958963 try {
959- Consumer callback = k .getReply ();
960- Utility .use (callback );
964+ k .getReply (); // discard result
961965 } catch (ShutdownSignalException ex ) {
962966 throw wrap (ex );
963967 }
0 commit comments