Bug 61274 - Fail on error with spawn=true
Summary: Fail on error with spawn=true
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-10 12:40 UTC by Tomas Tulka
Modified: 2017-07-10 12:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Tulka 2017-07-10 12:40:30 UTC
Hi,
When I start a long-running process (such as a database system) with spawn=true I would like to know if the process doesn't crash already on the beginning (for instance the database system didn't start at all due to a blocked port etc).

Ant script can wait for the process in a separate thread and report a failure.

The class org.apache.tools.ant.taskdefs.Execute could be modified like this:

line 524:

new Thread(new Runnable() {
            public void run() {
                try {
                    process.waitFor();

                    int returnCode = process.exitValue();

                    if (Execute.isFailure(returnCode)) {
                        if (failOnError) {
                            throw new BuildException(process + " returned: " + returnCode);
                        }
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }).start();

Thank you very much for any oppinion!

Tomas Tulka