diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index c59d60e3d..538920670 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -47,7 +47,9 @@ import org.apache.tools.ant.util.FileUtils; */ public class Execute { - /** Invalid exit code. **/ + /** Invalid exit code. + * set to {@link Integer#MAX_VALUE} + */ public static final int INVALID = Integer.MAX_VALUE; private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); @@ -586,6 +588,16 @@ public class Execute { ? (exitValue % 2 == 0) : (exitValue != 0); } + /** + * Did this execute return in a failure. + * @see #isFailure(int) + * @return true if and only if the exit code is interpreted as a failure + * @since Ant1.7 + */ + public boolean isFailure() { + return isFailure(getExitValue()); + } + /** * Test for an untimely death of the process. * @return true if a watchdog had to kill the process. diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java index ddfebdecd..b1e0cd23e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java @@ -65,9 +65,8 @@ public class ForkingSunRmic extends DefaultRmicAdapter { exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(args); - exe.execute(); - return exe.getExitValue() == 0; + return !exe.isFailure(); } catch (IOException exception) { throw new BuildException("Error running " + SunRmic.RMIC_EXECUTABLE + " -maybe it is not on the path", exception); diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java index 7c35a912b..d9ec9e492 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java @@ -27,12 +27,12 @@ import java.io.*; */ public class ExecuteWatchdogTest extends TestCase { - private final static int TIME_OUT = 5000; + private final static long TIME_OUT = 5000; private final static String TEST_CLASSPATH = getTestClassPath(); private final static int CLOCK_ERROR=200; - private final static int TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; + private final static long TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; private ExecuteWatchdog watchdog; @@ -58,7 +58,7 @@ public class ExecuteWatchdogTest extends TestCase { return classpath; } - private Process getProcess(int timetorun) throws Exception { + private Process getProcess(long timetorun) throws Exception { String[] cmdArray = { JavaEnvUtils.getJreExecutable("java"), "-classpath", TEST_CLASSPATH, TimeProcess.class.getName(), String.valueOf(timetorun) @@ -94,7 +94,7 @@ public class ExecuteWatchdogTest extends TestCase { watchdog.start(process); int retCode = waitForEnd(process); assertTrue("process should not have been killed", !watchdog.killedProcess()); - assertEquals(0, retCode); + assertFalse(Execute.isFailure(retCode)); } // test that the watchdog ends the process