mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
[175328] NPE on SSH Disconnect
This commit is contained in:
parent
879fb3d816
commit
2848dc80ff
1 changed files with 19 additions and 6 deletions
|
@ -120,8 +120,7 @@ public class SshConnectorService extends StandardConnectorService implements ISs
|
||||||
Activator.trace("SshConnectorService.connected"); //$NON-NLS-1$
|
Activator.trace("SshConnectorService.connected"); //$NON-NLS-1$
|
||||||
} catch (JSchException e) {
|
} catch (JSchException e) {
|
||||||
Activator.trace("SshConnectorService.connect failed: "+e.toString()); //$NON-NLS-1$
|
Activator.trace("SshConnectorService.connect failed: "+e.toString()); //$NON-NLS-1$
|
||||||
if (session.isConnected())
|
sessionDisconnect();
|
||||||
session.disconnect();
|
|
||||||
if(e.toString().indexOf("Auth cancel")>=0) { //$NON-NLS-1$
|
if(e.toString().indexOf("Auth cancel")>=0) { //$NON-NLS-1$
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
|
@ -132,6 +131,23 @@ public class SshConnectorService extends StandardConnectorService implements ISs
|
||||||
notifyConnection();
|
notifyConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect the ssh session.
|
||||||
|
* Synchronized in order to avoid NPE's from Jsch when called
|
||||||
|
* quickly in succession.
|
||||||
|
*/
|
||||||
|
private synchronized void sessionDisconnect() {
|
||||||
|
Activator.trace("SshConnectorService.sessionDisconnect"); //$NON-NLS-1$
|
||||||
|
try {
|
||||||
|
if (session.isConnected())
|
||||||
|
session.disconnect();
|
||||||
|
} catch(Exception e) {
|
||||||
|
//Bug 175328: NPE on disconnect shown in UI
|
||||||
|
//This is a non-critical exception so print only in debug mode
|
||||||
|
if (Activator.isTracingOn()) e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void internalDisconnect(IProgressMonitor monitor) throws Exception
|
protected void internalDisconnect(IProgressMonitor monitor) throws Exception
|
||||||
{
|
{
|
||||||
//TODO Will services like the sftp service be disconnected too? Or notified?
|
//TODO Will services like the sftp service be disconnected too? Or notified?
|
||||||
|
@ -151,10 +167,7 @@ public class SshConnectorService extends StandardConnectorService implements ISs
|
||||||
// Fire comm event to signal state about to change
|
// Fire comm event to signal state about to change
|
||||||
fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT);
|
fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT);
|
||||||
}
|
}
|
||||||
|
sessionDisconnect();
|
||||||
if (session.isConnected()) {
|
|
||||||
session.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire comm event to signal state changed
|
// Fire comm event to signal state changed
|
||||||
notifyDisconnection();
|
notifyDisconnection();
|
||||||
|
|
Loading…
Add table
Reference in a new issue