[ 
http://issues.apache.org/jira/browse/HADOOP-488?page=comments#action_12431289 ] 
            
Michel Tourn commented on HADOOP-488:
-------------------------------------

System.exit is also bad bec. it is "non-composable": 
it gets in the way of  tools that try to run other tools in the same JVM (like 
ant and junit and pot. TaskRunner)

However this proposal is not about using System.exit more than before. It is 
about exposing additional information, should you choose to use System.exit.

Usage as before: 

use doMain() from other Java code, like integration tests. This does not call 
System.exit()

use main() from a top-level application that integrates with shell tools: these 
tools only understand status codes, not Java exceptions. This calls 
System.exit()

Now in both cases, the caller has access to the status code.

+1







> Change ToolBase.doMain() to return a status code
> ------------------------------------------------
>
>                 Key: HADOOP-488
>                 URL: http://issues.apache.org/jira/browse/HADOOP-488
>             Project: Hadoop
>          Issue Type: Improvement
>    Affects Versions: 0.6.0
>            Reporter: Andrzej Bialecki 
>             Fix For: 0.6.0
>
>
> I propose to change the signature of ToolBase.doMain from this:
>     public final void doMain(Configuration conf, String[] args) throws 
> Exception;
> to this:
>     public final int doMain(Configuration conf, String[] args) throws 
> Exception;
> and then change main() methods of all classes that use ToolBase.doMain to 
> call System.exit(code), where "code" is this return value from doMain(). All 
> command-line tools, which still call main() methods of other tools, should be 
> converted to use doMain() and return exit codes properly.
> The main reason for this change is that returning varying exit codes is 
> required for proper operation of shell scripts, especially differing between 
> code == 0 (normal exit) and code != 0 (error exit).
> Additionally, current implementation of doMain() already gets the return 
> code, it just silently discards it (ToolBase.java:184).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to