diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java index fc9d7768e..d6a0f40d6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java @@ -518,7 +518,12 @@ public class ExecTask extends Task { //test for and handle a forced process death 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); if (Execute.isFailure(returnCode)) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index e1f0b82e0..b7ee3a7c2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -569,8 +569,8 @@ public class Execute { /** * 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() { return exitValue; @@ -1153,4 +1153,4 @@ public class Execute { } } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java index 14e4aef6e..6cce7c262 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -691,6 +691,9 @@ public class Java extends Task { redirector.createStreams(); exe.execute(getProject()); redirector.complete(); + if (exe.killedProcess()) { + throw new BuildException("Timeout: killed the sub-process"); + } } catch (IOException e) { throw new BuildException(e); } @@ -728,10 +731,10 @@ public class Java extends Task { exe.setCommandline(command); try { int rc = exe.execute(); + redirector.complete(); if (exe.killedProcess()) { - log("Timeout: killed the sub-process", Project.MSG_WARN); + throw new BuildException("Timeout: killed the sub-process"); } - redirector.complete(); return rc; } catch (IOException e) { throw new BuildException(e, getLocation());