bodewig 2003/10/24 01:49:11 Modified: src/main/org/apache/tools/ant/taskdefs/optional/ssh SSHExec.java Log: Catch insanely small timeouts (i.e. it occurs before we even start to execute the command), PR 23992 Revision Changes Path 1.10 +17 -3 ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java Index: SSHExec.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- SSHExec.java 28 Aug 2003 07:10:40 -0000 1.9 +++ SSHExec.java 24 Oct 2003 08:49:11 -0000 1.10 @@ -65,6 +65,7 @@ import java.io.StringReader; import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; /** @@ -93,6 +94,9 @@ 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 @@ 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 @@ } } } - } 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);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]