@@ -113,11 +113,11 @@ public void sessionNegotiationOptionsCreated(Session session, Map<KexProposalOpt
113113 } catch (SshException e ) {
114114 IoWriteFuture future = debugMsg .get ();
115115 assertNotNull (future , "No SSH_MSG_DEBUG" );
116- assertTrue (future .isWritten (), "SSH_MSG_DEBUG should have been sent" );
117116 // Due to a race condition in the Nio2 transport when closing a connection due to an exception it's possible
118117 // that we do _not_ get the expected disconnection code. The race condition may lead to the IoSession being
119118 // closed in the peer before it has sent the DISCONNECT message. Happens in particular on Windows.
120119 if (e .getDisconnectCode () == SshConstants .SSH2_DISCONNECT_KEY_EXCHANGE_FAILED ) {
120+ assertTrue (future .isWritten (), "SSH_MSG_DEBUG should have been sent" );
121121 assertTrue (e .getMessage ()
122122 .startsWith ("KEX: strict KEX negotiated but there were 1 messages before the first SSH_MSG_KEXINIT" ),
123123 "Unexpected disconnect reason: " + e .getMessage ());
@@ -162,8 +162,8 @@ public void sessionNegotiationEnd(
162162 } catch (SshException e ) {
163163 IoWriteFuture future = debugMsg .get ();
164164 assertNotNull (future , "No SSH_MSG_DEBUG" );
165- assertTrue (future .isWritten (), "SSH_MSG_DEBUG should have been sent" );
166165 if (e .getDisconnectCode () == SshConstants .SSH2_DISCONNECT_KEY_EXCHANGE_FAILED ) {
166+ assertTrue (future .isWritten (), "SSH_MSG_DEBUG should have been sent" );
167167 assertEquals ("SSH_MSG_DEBUG not allowed during initial key exchange in strict KEX" , e .getMessage (),
168168 "Unexpected disconnect reason" );
169169 }
0 commit comments