1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-08 11:03:28 +02:00

Bug 470525 - Handle remote connection parser initialization failure

gracefully

Change-Id: Ie6440b3c0310e15ebb404d5e0deff48eb9722635
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2015-06-18 16:16:18 -04:00
parent f743d07e7e
commit f48e9c35f2
3 changed files with 14 additions and 11 deletions

View file

@ -77,45 +77,45 @@ public class RemoteConnectionManager extends Job {
remoteConnection = connType.getConnection(connector.getRemoteSettings().getConnectionName()); remoteConnection = connType.getConnection(connector.getRemoteSettings().getConnectionName());
} }
if (remoteConnection == null) { if (remoteConnection == null) {
throw new RemoteConnectionException( return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
NLS.bind(Messages.RemoteConnectionManager_0, connector.getRemoteSettings().getConnectionName())); NLS.bind(Messages.RemoteConnectionManager_0, connector.getRemoteSettings().getConnectionName()));
} }
if (!remoteConnection.isOpen()) { if (!remoteConnection.isOpen()) {
remoteConnection.open(monitor); remoteConnection.open(monitor);
if (!remoteConnection.isOpen()) { if (!remoteConnection.isOpen()) {
throw new RemoteConnectionException( return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
NLS.bind(Messages.RemoteConnectionManager_1, connector.getRemoteSettings().getConnectionName())); NLS.bind(Messages.RemoteConnectionManager_1, connector.getRemoteSettings().getConnectionName()));
} }
} }
if (parser != null) { if (parser != null) {
synchronized (this) { remoteProcess = parser.initialize(remoteConnection);
remoteProcess = parser.initialize(remoteConnection); }
}
} else { if (remoteProcess == null) {
/* /*
* Check the terminal shell command preference. If the preference is empty and we support a command shell, * Check the terminal shell command preference. If the preference is empty and we support a command shell,
* just use that. Otherwise use the preference value if it is set, or fall back to a default if not. * just use that. Otherwise use the preference value if it is set, or fall back to a default if not.
*/ */
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier()); IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
String terminalShellCommand = prefs.get(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND, ""); //$NON-NLS-1$ String terminalShellCommand = prefs.get(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND, ""); //$NON-NLS-1$
if (!("".equals(terminalShellCommand)) //$NON-NLS-1$ if ("".equals(terminalShellCommand) //$NON-NLS-1$
&& remoteConnection.hasService(IRemoteCommandShellService.class)) { && remoteConnection.hasService(IRemoteCommandShellService.class)) {
IRemoteCommandShellService cmdShellSvc = remoteConnection.getService(IRemoteCommandShellService.class); IRemoteCommandShellService cmdShellSvc = remoteConnection.getService(IRemoteCommandShellService.class);
synchronized (this) { synchronized (this) {
remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY); remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
} }
} else { } else if (remoteConnection.hasService(IRemoteProcessService.class)) {
if ("".equals(terminalShellCommand)) { //$NON-NLS-1$ if ("".equals(terminalShellCommand)) { //$NON-NLS-1$
terminalShellCommand = "/bin/bash -l"; //$NON-NLS-1$ terminalShellCommand = "/bin/bash -l"; //$NON-NLS-1$
} }
IRemoteProcessService procSvc = remoteConnection.getService(IRemoteProcessService.class); IRemoteProcessService procSvc = remoteConnection.getService(IRemoteProcessService.class);
IRemoteProcessBuilder processBuilder = procSvc IRemoteProcessBuilder processBuilder = procSvc
.getProcessBuilder(new ArgumentParser(terminalShellCommand).getTokenList()); .getProcessBuilder(new ArgumentParser(terminalShellCommand).getTokenList());
synchronized (this) { remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY);
remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY); } else {
} return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), Messages.RemoteConnectionManager_2);
} }
} }

View file

@ -16,6 +16,8 @@ public class Messages extends NLS {
public static String RemoteConnectionManager_1; public static String RemoteConnectionManager_1;
public static String RemoteConnectionManager_2;
public static String RemoteTerminalPreferencePage_0; public static String RemoteTerminalPreferencePage_0;
public static String TERMINAL_EXCEPTION; public static String TERMINAL_EXCEPTION;

View file

@ -9,6 +9,7 @@
############################################################################### ###############################################################################
RemoteConnectionManager_0=Unable to create connection: {0} RemoteConnectionManager_0=Unable to create connection: {0}
RemoteConnectionManager_1=Unable to to open connection: {0} RemoteConnectionManager_1=Unable to to open connection: {0}
RemoteConnectionManager_2=Connection type does not support the required services
RemoteTerminalPreferencePage_0=Initial Shell Command RemoteTerminalPreferencePage_0=Initial Shell Command
TERMINAL_EXCEPTION=Remote Terminal Exception TERMINAL_EXCEPTION=Remote Terminal Exception