https://bz.apache.org/bugzilla/show_bug.cgi?id=59228

            Bug ID: 59228
           Summary: <ant>/<antcall> does not preserve exit status from
                    <fail> on error
           Product: Ant
           Version: 1.9.6
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
          Assignee: [email protected]
          Reporter: [email protected]

The <ant>/<antcall> does not preserve the exit status specified in a <fail>
task when the application exits. Below is a simple test case that illustrates
the problem:

<project name="build" default="t1">
    <target name="t1">
        <antcall target="t2" />
    </target>
    <target name="t2">
        <fail message="Failing with a 2" status="2" />
    </target>
</project>

The expectation is that when Ant exits, the error code (%ERRORLEVEL% on
Windows, $? on UNIX) should be 2. However the observed result is that the error
code is set to 1 instead.

At the code level, this is because
ProjectHelper.addLocationToBuildException(BuildException, Location) always
throws a new BuildException regardless of whether the original exception is an
ExitStatusException. The proposed solution is to check whether the original
exception is an ExitStatusException, and if so, throw a new ExitStatusException
with the status code from the original ExceptionStatusException.

Refer to my pull request on Github for a proposed implementation. If the
original patch submission method is preferred, let me know and I can do that
too.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to