1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00

Merge "Bug 437083 - Improve error message if ssh fails"

This commit is contained in:
Greg Watson 2014-07-29 09:14:21 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 559dd99ea8
3 changed files with 12 additions and 14 deletions

View file

@ -171,7 +171,6 @@ public class JSchConnection implements IRemoteConnection {
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
private String fWorkingDir;
private boolean fIsOpen;
private final IJSchService fJSchService;
@ -263,7 +262,6 @@ public class JSchConnection implements IRemoteConnection {
}
}
fSessions.clear();
fIsOpen = false;
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
}
@ -661,7 +659,7 @@ public class JSchConnection implements IRemoteConnection {
*/
@Override
public boolean isOpen() {
boolean isOpen = fIsOpen & fSessions.size() > 0;
boolean isOpen = fSessions.size() > 0;
if (isOpen) {
for (Session session : fSessions) {
isOpen &= session.isConnected();
@ -814,23 +812,18 @@ public class JSchConnection implements IRemoteConnection {
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
if (!isOpen()) {
checkIsConfigured();
SubMonitor subMon = SubMonitor.convert(monitor, 70);
SubMonitor subMon = SubMonitor.convert(monitor, 60);
Session session = newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
if (subMon.isCanceled()) {
throw new RemoteConnectionException(Messages.JSchConnection_Connection_was_cancelled);
}
//getCwd checks the exec channel before checkConfiguration checks the sftp channel
fWorkingDir = getCwd(subMon.newChild(10));
if (!checkConfiguration(session, subMon.newChild(20))) {
newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
loadEnv(subMon.newChild(10));
}
fIsOpen = true;
try {
fWorkingDir = getCwd(subMon.newChild(10));
loadProperties(subMon.newChild(10));
} catch (RemoteConnectionException e) {
fIsOpen = false;
throw e;
}
loadProperties(subMon.newChild(10));
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
}
}

View file

@ -126,7 +126,7 @@ public abstract class AbstractRemoteCommand<T> {
* @see java.util.concurrent.Callable#call()
*/
@Override
public abstract T1 call() throws JSchException, IOException;
public abstract T1 call() throws JSchException, IOException, RemoteConnectionException;
private void finalizeCmdInThread() {
setChannel(null);

View file

@ -29,10 +29,12 @@ public class ExecCommand extends AbstractRemoteCommand<String> {
final SubMonitor subMon = SubMonitor.convert(monitor, 10);
ExecCallable<String> c = new ExecCallable<String>() {
@Override
public String call() throws JSchException {
public String call() throws JSchException, RemoteConnectionException {
getChannel().setCommand(fCommand);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
getChannel().setOutputStream(stream);
getChannel().setErrStream(err);
getChannel().connect();
while (!getChannel().isClosed() && !getProgressMonitor().isCanceled()) {
synchronized (this) {
@ -46,6 +48,9 @@ public class ExecCommand extends AbstractRemoteCommand<String> {
if (getProgressMonitor().isCanceled()) {
return ""; //$NON-NLS-1$
}
if (getChannel().getExitStatus()!=0) {
throw new RemoteConnectionException(err.toString());
}
return stream.toString();
}
};