@@ -249,16 +249,7 @@ public void releaseChannelNumber() {
249249 // We're in normal running mode.
250250
251251 if (method instanceof Channel .Close ) {
252- releaseChannelNumber ();
253- ShutdownSignalException signal = new ShutdownSignalException (false ,
254- false ,
255- command ,
256- this );
257- synchronized (_channelMutex ) {
258- processShutdownSignal (signal , true , true );
259- quiescingTransmit (new Channel .CloseOk ());
260- }
261- notifyListeners ();
252+ asyncShutdown (command );
262253 return true ;
263254 } else if (method instanceof Basic .Deliver ) {
264255 Basic .Deliver m = (Basic .Deliver ) method ;
@@ -357,16 +348,7 @@ public void releaseChannelNumber() {
357348
358349 if (method instanceof Channel .Close ) {
359350 // We are already shutting down, but we cannot assume no Rpc is waiting.
360- releaseChannelNumber ();
361- ShutdownSignalException signal = new ShutdownSignalException (false ,
362- false ,
363- command ,
364- this );
365- synchronized (_channelMutex ) {
366- processShutdownSignal (signal , true , true );
367- quiescingTransmit (new Channel .CloseOk ());
368- }
369- notifyListeners ();
351+ asyncShutdown (command );
370352 return true ;
371353 } else if (method instanceof Channel .CloseOk ) {
372354 // We're quiescing, and we see a channel.close-ok:
@@ -383,6 +365,19 @@ public void releaseChannelNumber() {
383365 }
384366 }
385367
368+ private void asyncShutdown (Command command ) throws IOException {
369+ releaseChannelNumber ();
370+ ShutdownSignalException signal = new ShutdownSignalException (false ,
371+ false ,
372+ command ,
373+ this );
374+ synchronized (_channelMutex ) {
375+ processShutdownSignal (signal , true , true );
376+ quiescingTransmit (new Channel .CloseOk ());
377+ }
378+ notifyListeners ();
379+ }
380+
386381 /** Public API - {@inheritDoc} */
387382 public void close ()
388383 throws IOException
0 commit comments