@@ -241,12 +241,12 @@ public void setDefaultConsumer(Consumer consumer) {
241241 * Sends a ShutdownSignal to all active consumers.
242242 * @param signal an exception signalling channel shutdown
243243 */
244- private CountDownLatch broadcastShutdownSignal (ShutdownSignalException signal ) {
244+ private void broadcastShutdownSignal (ShutdownSignalException signal ) {
245245 Map <String , Consumer > snapshotConsumers ;
246246 synchronized (_consumers ) {
247247 snapshotConsumers = new HashMap <String , Consumer >(_consumers );
248248 }
249- return this .dispatcher .handleShutdownSignal (snapshotConsumers , signal );
249+ this . finishedShutdownFlag = this .dispatcher .handleShutdownSignal (snapshotConsumers , signal );
250250 }
251251
252252 /**
@@ -257,9 +257,7 @@ private CountDownLatch broadcastShutdownSignal(ShutdownSignalException signal) {
257257 boolean ignoreClosed ,
258258 boolean notifyRpc )
259259 {
260- this .dispatcher .quiesce ();
261260 super .processShutdownSignal (signal , ignoreClosed , notifyRpc );
262- this .finishedShutdownFlag = broadcastShutdownSignal (signal );
263261 synchronized (unconfirmedSet ) {
264262 unconfirmedSet .notifyAll ();
265263 }
@@ -526,7 +524,14 @@ public void close(int closeCode,
526524 signal .initCause (cause );
527525 }
528526
529- BlockingRpcContinuation <AMQCommand > k = new SimpleBlockingRpcContinuation ();
527+ BlockingRpcContinuation <AMQCommand > k = new BlockingRpcContinuation <AMQCommand >(){
528+ @ Override
529+ public AMQCommand transformReply (AMQCommand command ) {
530+ ChannelN .this .dispatcher .quiesce ();
531+ broadcastShutdownSignal (getCloseReason ());
532+
533+ return command ;
534+ }};
530535 boolean notify = false ;
531536 try {
532537 // Synchronize the block below to avoid race conditions in case
@@ -536,10 +541,10 @@ public void close(int closeCode,
536541 quiescingRpc (reason , k );
537542 }
538543
539- // Now that we're in quiescing state, channel.close was sent and
540- // we wait for the reply. We ignore the result.
541- // (It's NOT always close-ok.)
542- notify = true ;
544+ // Now that we're in quiescing state, channel.close was sent and
545+ // we wait for the reply. We ignore the result.
546+ // (It's NOT always close-ok.)
547+ notify = true ;
543548 k .getReply (-1 );
544549 } catch (TimeoutException ise ) {
545550 // Will never happen since we wait infinitely
0 commit comments