@@ -457,26 +457,15 @@ public MainLoop() {
457457 }
458458 }
459459 } catch (EOFException ex ) {
460- if (isOpen ()) {
461- System .err .println ("AMQConnection.mainLoop: connection close" );
462- shutdown (ex , false , ex );
463- }
460+ shutdown (ex , false , ex );
464461 } catch (Throwable ex ) {
465462 _exceptionHandler .handleUnexpectedConnectionDriverException (AMQConnection .this ,
466463 ex );
467- if (isOpen ()) {
468- shutdown (ex , false , ex );
469- }
464+ shutdown (ex , false , ex );
470465 } finally {
471466 // Finally, shut down our underlying data connection.
472467 _frameHandler .close ();
473468
474- // Set shutdown exception for any outstanding rpc,
475- // so that it does not wait infinitely for Connection.CloseOk.
476- // This can only happen when the broker closed the socket
477- // unexpectedly.
478- _channel0 .notifyOutstandingRpc (_shutdownCause );
479-
480469 _appContinuation .set (null );
481470 notifyListeners ();
482471 }
@@ -599,22 +588,27 @@ public void shutdown(Object reason,
599588 boolean initiatedByApplication ,
600589 Throwable cause )
601590 {
591+
592+ ShutdownSignalException sse = new ShutdownSignalException (true ,initiatedByApplication ,
593+ reason , this );
594+ sse .initCause (cause );
602595 try {
603596 synchronized (this ) {
604597 ensureIsOpen (); // invariant: we should never be shut down more than once per instance
605- ShutdownSignalException sse = new ShutdownSignalException (true ,
606- initiatedByApplication ,
607- reason , this );
608- sse .initCause (cause );
609598 _shutdownCause = sse ;
610599 }
611-
612- _channel0 .processShutdownSignal (_shutdownCause );
613600 } catch (AlreadyClosedException ace ) {
614601 if (initiatedByApplication )
615602 throw ace ;
603+ } finally {
604+ try {
605+ _channel0 .processShutdownSignal (sse );
606+ } catch (AlreadyClosedException ace ) {
607+ if (initiatedByApplication )
608+ throw ace ;
609+ }
616610 }
617- _channelManager .handleSignal (_shutdownCause );
611+ _channelManager .handleSignal (sse );
618612 }
619613
620614 /**
0 commit comments