Skip to content

Conversation

@exceptionfactory
Copy link
Contributor

The current KeepAlive.setKeepAliveInterval() method starts the Thread when invoked with an interval greater than zero. This behavior starts the KeepAlive Thread prior to establishing a connection, depending on when the caller invokes setKeepAliveInterval().

Neither the ConnectionImpl class nor the SSHClient class interrupt the KeepAlive Thread, resulting in continued looping inside of KeepAlive.run() even after disconnecting and closing SSHClient as described in issue #506.

This pull request changes the behavior of KeepAlive.setKeepAliveInterval() to avoid starting the Thread. The SSHClient.onConnect() method checks whether the KeepAlive Thread is enabled and then calls start() to avoid unnecessary execution prior to a successful connection. The SSHClient.disconnect() method interrupts the KeepAlive Thread to ensure that it does not continue running. The KeepAliveThreadTerminationTest includes an additional method to verify the initial state of the KeepAlive Thread, as well as the state after connecting and disconnecting.

…ierynomus#506)

- Changed KeepAlive.setKeepAliveInterval() to avoid starting Thread
- Updated SSHClient.onConnect() to start KeepAlive Thread when enabled
- Updated SSHClient.disconnect() to interrupt KeepAlive Thread
- Updated KeepAliveThreadTerminationTest to verify state of KeepAlive Thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants