mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 23:30:55 +03:00
Some more cleanups for handling disconnects
This commit is contained in:
@@ -57,7 +57,7 @@ public abstract class AbstractService
|
||||
|
||||
@Override
|
||||
public void notifyError(SSHException error) {
|
||||
log.debug("Was notified of {}", error.toString());
|
||||
log.debug("Notified of {}", error.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,12 +66,6 @@ public abstract class AbstractService
|
||||
throw new SSHException(DisconnectReason.PROTOCOL_ERROR, "Unexpected: SSH_MSG_UNIMPLEMENTED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDisconnect(DisconnectReason reason)
|
||||
throws SSHException {
|
||||
log.debug("Was notified of disconnect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void request()
|
||||
throws TransportException {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package net.schmizz.sshj;
|
||||
|
||||
import net.schmizz.sshj.common.DisconnectReason;
|
||||
import net.schmizz.sshj.common.ErrorNotifiable;
|
||||
import net.schmizz.sshj.common.SSHException;
|
||||
import net.schmizz.sshj.common.SSHPacketHandler;
|
||||
@@ -49,7 +48,4 @@ public interface Service
|
||||
void request()
|
||||
throws TransportException;
|
||||
|
||||
void notifyDisconnect(DisconnectReason reason)
|
||||
throws SSHException;
|
||||
|
||||
}
|
||||
@@ -140,19 +140,6 @@ public class ConnectionImpl
|
||||
super.handle(msg, buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyError(SSHException error) {
|
||||
super.notifyError(error);
|
||||
|
||||
synchronized (globalReqFutures) {
|
||||
FutureUtils.alertAll(error, globalReqFutures);
|
||||
globalReqFutures.clear();
|
||||
}
|
||||
|
||||
ErrorNotifiable.Util.alertAll(error, channels.values());
|
||||
channels.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPacketSize() {
|
||||
return maxPacketSize;
|
||||
@@ -246,12 +233,14 @@ public class ConnectionImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDisconnect(DisconnectReason reason)
|
||||
throws SSHException {
|
||||
super.notifyDisconnect(reason);
|
||||
final ConnectionException ex = new ConnectionException("Disconnected");
|
||||
FutureUtils.alertAll(ex, globalReqFutures);
|
||||
ErrorNotifiable.Util.alertAll(ex, new HashSet<Channel>(channels.values()));
|
||||
public void notifyError(SSHException error) {
|
||||
super.notifyError(error);
|
||||
synchronized (globalReqFutures) {
|
||||
FutureUtils.alertAll(error, globalReqFutures);
|
||||
globalReqFutures.clear();
|
||||
}
|
||||
ErrorNotifiable.Util.alertAll(error, channels.values());
|
||||
channels.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -380,11 +380,7 @@ public final class TransportImpl
|
||||
close.lock();
|
||||
try {
|
||||
disconnectListener.notifyDisconnect(reason);
|
||||
try {
|
||||
service.notifyDisconnect(reason);
|
||||
} catch (SSHException logged) {
|
||||
log.warn("{} did not handle disconnect cleanly: {}", service, logged);
|
||||
}
|
||||
getService().notifyError(new TransportException(reason, "Disconnected"));
|
||||
if (!close.isSet()) {
|
||||
sendDisconnect(reason, message);
|
||||
finishOff();
|
||||
|
||||
Reference in New Issue
Block a user