@@ -217,12 +217,12 @@ private void checkBothSidesClosed() {
217
217
}
218
218
219
219
private void notifyWaitingPOs (POObject [] po ) {
220
- for (int i = 0 ; i < po . length ; i ++ ) {
221
- if (po [ i ] != null ) {
222
- po [ i ] .setSuccess (false );
223
- if (po [ i ] .getException () == null )
224
- po [ i ] .setException ("Connection was asynchronously closed" );
225
- po [ i ] .getSemaphore ().notifySingleWaiter ();
220
+ for (POObject poObject : po ) {
221
+ if (poObject != null ) {
222
+ poObject .setSuccess (false );
223
+ if (poObject .getException () == null )
224
+ poObject .setException ("Connection was asynchronously closed" );
225
+ poObject .getSemaphore ().notifySingleWaiter ();
226
226
}
227
227
}
228
228
}
@@ -584,8 +584,15 @@ public void visit(EndFrame frame) {
584
584
585
585
public void visit (CloseFrame frame ) {
586
586
if (pTracer .isEnabled ()) pTracer .trace (toString (), ", visit=" + frame );
587
- remoteClose = frame ;
588
- checkBothSidesClosed ();
587
+ // Async remote close due to error
588
+ if (frame .getError () != null ) {
589
+ if (myConnection .getExceptionListener () != null )
590
+ myConnection .getExceptionListener ().onException (new ConnectionClosedException (frame .getError ().getDescription ().getValue ()));
591
+ new Thread (() -> myConnection .cancel ()).start ();
592
+ } else {
593
+ remoteClose = frame ;
594
+ checkBothSidesClosed ();
595
+ }
589
596
}
590
597
591
598
public void visit (SaslMechanismsFrame frame ) {
0 commit comments