Browse Source

Catch insanely small timeouts (i.e. it occurs before we even start to execute the command), PR 23992

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275563 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
e19a2de440
1 changed files with 16 additions and 2 deletions
  1. +16
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java

+ 16
- 2
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java View File

@@ -65,6 +65,7 @@ import java.io.IOException;
import java.io.StringReader;

import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;

/**
@@ -93,6 +94,9 @@ public class SSHExec extends SSHBase {
private File outputFile = null; // like <exec>
private boolean append = false; // like <exec>

private static final String TIMEOUT_MESSAGE =
"Timeout period exceeded, connection dropped.";

/**
* Constructor for SSHExecTask.
*/
@@ -205,7 +209,7 @@ public class SSHExec extends SSHBase {
if (thread.isAlive()) {
// ran out of time
thread = null;
log("Timeout period exceeded, connection dropped.");
log(TIMEOUT_MESSAGE, Project.MSG_ERR);
} else {
// completed successfully
if (outputProperty != null) {
@@ -227,9 +231,19 @@ public class SSHExec extends SSHBase {
}
}
}

} catch (BuildException e) {
throw e;
} catch (JSchException e) {
if (e.getMessage().indexOf("session is down") >= 0) {
log(TIMEOUT_MESSAGE, Project.MSG_ERR);
} else {
if (getFailonerror()) {
throw new BuildException(e);
} else {
log("Caught exception: " + e.getMessage(),
Project.MSG_ERR);
}
}
} catch (Exception e) {
if (getFailonerror()) {
throw new BuildException(e);


Loading…
Cancel
Save