mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Merge "Bug 437083 - Improve error message if ssh fails"
This commit is contained in:
commit
559dd99ea8
3 changed files with 12 additions and 14 deletions
|
@ -171,7 +171,6 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
private String fWorkingDir;
|
private String fWorkingDir;
|
||||||
private boolean fIsOpen;
|
|
||||||
|
|
||||||
private final IJSchService fJSchService;
|
private final IJSchService fJSchService;
|
||||||
|
|
||||||
|
@ -263,7 +262,6 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fSessions.clear();
|
fSessions.clear();
|
||||||
fIsOpen = false;
|
|
||||||
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
|
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +659,7 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
boolean isOpen = fIsOpen & fSessions.size() > 0;
|
boolean isOpen = fSessions.size() > 0;
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
for (Session session : fSessions) {
|
for (Session session : fSessions) {
|
||||||
isOpen &= session.isConnected();
|
isOpen &= session.isConnected();
|
||||||
|
@ -814,23 +812,18 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
|
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
checkIsConfigured();
|
checkIsConfigured();
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 70);
|
SubMonitor subMon = SubMonitor.convert(monitor, 60);
|
||||||
Session session = newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
|
Session session = newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
|
||||||
if (subMon.isCanceled()) {
|
if (subMon.isCanceled()) {
|
||||||
throw new RemoteConnectionException(Messages.JSchConnection_Connection_was_cancelled);
|
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))) {
|
if (!checkConfiguration(session, subMon.newChild(20))) {
|
||||||
newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
|
newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
|
||||||
loadEnv(subMon.newChild(10));
|
loadEnv(subMon.newChild(10));
|
||||||
}
|
}
|
||||||
fIsOpen = true;
|
|
||||||
try {
|
|
||||||
fWorkingDir = getCwd(subMon.newChild(10));
|
|
||||||
loadProperties(subMon.newChild(10));
|
loadProperties(subMon.newChild(10));
|
||||||
} catch (RemoteConnectionException e) {
|
|
||||||
fIsOpen = false;
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
|
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
* @see java.util.concurrent.Callable#call()
|
* @see java.util.concurrent.Callable#call()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public abstract T1 call() throws JSchException, IOException;
|
public abstract T1 call() throws JSchException, IOException, RemoteConnectionException;
|
||||||
|
|
||||||
private void finalizeCmdInThread() {
|
private void finalizeCmdInThread() {
|
||||||
setChannel(null);
|
setChannel(null);
|
||||||
|
|
|
@ -29,10 +29,12 @@ public class ExecCommand extends AbstractRemoteCommand<String> {
|
||||||
final SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
final SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
||||||
ExecCallable<String> c = new ExecCallable<String>() {
|
ExecCallable<String> c = new ExecCallable<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call() throws JSchException {
|
public String call() throws JSchException, RemoteConnectionException {
|
||||||
getChannel().setCommand(fCommand);
|
getChannel().setCommand(fCommand);
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
ByteArrayOutputStream err = new ByteArrayOutputStream();
|
||||||
getChannel().setOutputStream(stream);
|
getChannel().setOutputStream(stream);
|
||||||
|
getChannel().setErrStream(err);
|
||||||
getChannel().connect();
|
getChannel().connect();
|
||||||
while (!getChannel().isClosed() && !getProgressMonitor().isCanceled()) {
|
while (!getChannel().isClosed() && !getProgressMonitor().isCanceled()) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -46,6 +48,9 @@ public class ExecCommand extends AbstractRemoteCommand<String> {
|
||||||
if (getProgressMonitor().isCanceled()) {
|
if (getProgressMonitor().isCanceled()) {
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
if (getChannel().getExitStatus()!=0) {
|
||||||
|
throw new RemoteConnectionException(err.toString());
|
||||||
|
}
|
||||||
return stream.toString();
|
return stream.toString();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue