From 4c171cffa31203c18b554c6a05e2e5a3ea86cded Mon Sep 17 00:00:00 2001 From: Ungureanu Dan-B07892 Date: Wed, 23 Jul 2014 10:22:12 +0300 Subject: [PATCH] [306494] Prevent disconnect of wrong connection when handling SSH or TELNET connection loss Change-Id: I4cb6fe1a5d2c29dcd1145600cd88b1e333767148 Signed-off-by: Dan Ungureanu Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=306494 --- .../ssh/SshConnectorService.java | 33 ++++++------------ .../telnet/TelnetConnectorService.java | 34 ++++++------------- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java index b9dbb0afe48..e1db594e80a 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java @@ -319,17 +319,6 @@ public class SshConnectorService extends StandardConnectorService implements ISs public void run() { Shell shell = getShell(); - //TODO need a more correct message for "session lost" - //TODO allow users to reconnect from this dialog - //SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST); - - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, - ICommonMessageIds.MSG_CONNECT_CANCELLED, IStatus.CANCEL, - NLS.bind(CommonMessages.MSG_CONNECT_CANCELLED, - _connection.getHost().getAliasName())); - - SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg); - dialog.open(); try { //TODO I think we should better use a Job for disconnecting? @@ -342,21 +331,21 @@ public class SshConnectorService extends StandardConnectorService implements ISs ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); sr.connectedStatusChange(_connection.getPrimarySubSystem(), false, true, true); } - catch (InterruptedException exc) // user cancelled - { - if (shell != null) - showDisconnectCancelledMessage(shell, _connection.getHostName(), _connection.getPort()); - } - catch (java.lang.reflect.InvocationTargetException invokeExc) // unexpected error - { - Exception exc = (Exception)invokeExc.getTargetException(); - if (shell != null) - showDisconnectErrorMessage(shell, _connection.getHostName(), _connection.getPort(), exc); - } catch (Exception e) { SystemBasePlugin.logError(SshConnectorResources.SshConnectorService_ErrorDisconnecting, e); } + //TODO need a more correct message for "session lost" + //TODO allow users to reconnect from this dialog + //SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST); + + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + ICommonMessageIds.MSG_CONNECT_CANCELLED, IStatus.CANCEL, + NLS.bind(CommonMessages.MSG_CONNECT_CANCELLED, + _connection.getHost().getAliasName())); + + SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg); + dialog.open(); } public void run(IProgressMonitor monitor) diff --git a/rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java index bd51c8b5a7a..f988942cf83 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java @@ -370,17 +370,6 @@ public class TelnetConnectorService extends StandardConnectorService implements public void run() { Shell shell = getShell(); - // TODO need a more correct message for "session lost" - // TODO allow users to reconnect from this dialog - // SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST); - - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, - ICommonMessageIds.MSG_CONNECT_CANCELLED, - IStatus.CANCEL, - NLS.bind(CommonMessages.MSG_CONNECT_CANCELLED, _connection.getHost().getAliasName())); - - SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg); - dialog.open(); try { // TODO I think we should better use a Job for disconnecting? // But what about error messages? @@ -394,21 +383,20 @@ public class TelnetConnectorService extends StandardConnectorService implements ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); sr.connectedStatusChange(_connection.getPrimarySubSystem(), false, true, true); - } catch (InterruptedException exc) // user cancelled - { - if (shell != null) - showDisconnectCancelledMessage(shell, _connection - .getHostName(), _connection.getPort()); - } catch (java.lang.reflect.InvocationTargetException invokeExc) // unexpected error - { - Exception exc = (Exception) invokeExc.getTargetException(); - if (shell != null) - showDisconnectErrorMessage(shell, - _connection.getHostName(), _connection.getPort(), - exc); } catch (Exception e) { SystemBasePlugin.logError(TelnetConnectorResources.TelnetConnectorService_ErrorDisconnecting, e); } + // TODO need a more correct message for "session lost" + // TODO allow users to reconnect from this dialog + // SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST); + + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + ICommonMessageIds.MSG_CONNECT_CANCELLED, + IStatus.CANCEL, + NLS.bind(CommonMessages.MSG_CONNECT_CANCELLED, _connection.getHost().getAliasName())); + + SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg); + dialog.open(); } public void run(IProgressMonitor monitor)