Make disconnect() an operation that can be repeated without side-effects beyond the first call.

This commit is contained in:
Shikhar Bhushan
2012-01-08 10:20:46 +00:00
parent dbb3f62e82
commit 7e524f5c6f
2 changed files with 2 additions and 3 deletions

View File

@@ -362,7 +362,6 @@ public class SSHClient
@Override
public void disconnect()
throws IOException {
assert isConnected();
trans.disconnect();
super.disconnect();
assert !isConnected();

View File

@@ -381,9 +381,9 @@ public final class TransportImpl
public void disconnect(DisconnectReason reason, String message) {
close.lock();
try {
disconnectListener.notifyDisconnect(reason);
getService().notifyError(new TransportException(reason, "Disconnected"));
if (!close.isSet()) {
disconnectListener.notifyDisconnect(reason);
getService().notifyError(new TransportException(reason, "Disconnected"));
sendDisconnect(reason, message);
finishOff();
close.set();