Browse Source

Treat timeout like a failed execution, fix comments on Execute#getExitCode

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275258 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
36accb02b3
3 changed files with 14 additions and 6 deletions
  1. +6
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecTask.java
  2. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  3. +5
    -2
      src/main/org/apache/tools/ant/taskdefs/Java.java

+ 6
- 1
src/main/org/apache/tools/ant/taskdefs/ExecTask.java View File

@@ -518,7 +518,12 @@ public class ExecTask extends Task {


//test for and handle a forced process death //test for and handle a forced process death
if (exe.killedProcess()) { if (exe.killedProcess()) {
log("Timeout: killed the sub-process", Project.MSG_WARN);
String msg = "Timeout: killed the sub-process";
if (failOnError) {
throw new BuildException(msg);
} else {
log(msg, Project.MSG_WARN);
}
} }
maybeSetResultPropertyValue(returnCode); maybeSetResultPropertyValue(returnCode);
if (Execute.isFailure(returnCode)) { if (Execute.isFailure(returnCode)) {


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -569,8 +569,8 @@ public class Execute {


/** /**
* Query the exit value of the process. * Query the exit value of the process.
* @return the exit value, 1 if the process was killed,
* or Execute.INVALID if no exit value has been received
* @return the exit value or Execute.INVALID if no exit value has
* been received
*/ */
public int getExitValue() { public int getExitValue() {
return exitValue; return exitValue;
@@ -1153,4 +1153,4 @@ public class Execute {
} }


} }
}
}

+ 5
- 2
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -691,6 +691,9 @@ public class Java extends Task {
redirector.createStreams(); redirector.createStreams();
exe.execute(getProject()); exe.execute(getProject());
redirector.complete(); redirector.complete();
if (exe.killedProcess()) {
throw new BuildException("Timeout: killed the sub-process");
}
} catch (IOException e) { } catch (IOException e) {
throw new BuildException(e); throw new BuildException(e);
} }
@@ -728,10 +731,10 @@ public class Java extends Task {
exe.setCommandline(command); exe.setCommandline(command);
try { try {
int rc = exe.execute(); int rc = exe.execute();
redirector.complete();
if (exe.killedProcess()) { if (exe.killedProcess()) {
log("Timeout: killed the sub-process", Project.MSG_WARN);
throw new BuildException("Timeout: killed the sub-process");
} }
redirector.complete();
return rc; return rc;
} catch (IOException e) { } catch (IOException e) {
throw new BuildException(e, getLocation()); throw new BuildException(e, getLocation());


Loading…
Cancel
Save