Return-Path: Delivered-To: apmail-hadoop-core-dev-archive@www.apache.org Received: (qmail 23410 invoked from network); 29 Oct 2008 14:50:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Oct 2008 14:50:38 -0000 Received: (qmail 53217 invoked by uid 500); 29 Oct 2008 14:50:40 -0000 Delivered-To: apmail-hadoop-core-dev-archive@hadoop.apache.org Received: (qmail 53173 invoked by uid 500); 29 Oct 2008 14:50:40 -0000 Mailing-List: contact core-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-dev@hadoop.apache.org Received: (qmail 53162 invoked by uid 99); 29 Oct 2008 14:50:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Oct 2008 07:50:40 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Oct 2008 14:49:34 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id AE961234C24E for ; Wed, 29 Oct 2008 07:49:44 -0700 (PDT) Message-ID: <433656163.1225291784714.JavaMail.jira@brutus> Date: Wed, 29 Oct 2008 07:49:44 -0700 (PDT) From: "Nigel Daley (JIRA)" To: core-dev@hadoop.apache.org Subject: [jira] Updated: (HADOOP-4340) "hadoop jar" always returns exit code 0 (success) to the shell when jar throws a fatal exception In-Reply-To: <868142944.1223073704279.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HADOOP-4340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Nigel Daley updated HADOOP-4340: -------------------------------- Fix Version/s: 0.19.0 0.18.2 > "hadoop jar" always returns exit code 0 (success) to the shell when jar throws a fatal exception > ------------------------------------------------------------------------------------------------- > > Key: HADOOP-4340 > URL: https://issues.apache.org/jira/browse/HADOOP-4340 > Project: Hadoop Core > Issue Type: Bug > Components: examples, mapred > Affects Versions: 0.18.1, 0.19.0, 0.20.0 > Environment: Ubuntu 8.04 Server, 7 Hadoop nodes, GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu) > Reporter: David Litster > Assignee: Amareshwari Sriramadasu > Fix For: 0.18.2, 0.19.0 > > Attachments: patch-4340-1.txt, patch-4340.txt > > > Running "hadoop jar" always returns 0 (success) when the jar dies with a stack trace. As an example, run these commands: > /usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/hadoop-0.18.1-examples.jar pi 10 10 2>&1; echo $? > exits with 0 > /usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/hadoop-0.18.1-examples.jar pi 2>&1; echo $? > exits with 255 > /usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/hadoop-0.18.1-examples.jar 2>&1; echo $? > exits with 0 > This seems to be expected behavior. However, running: > /usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/hadoop-0.18.1-examples.jar pi 10 badparam 2>&1; echo $? > java.lang.NumberFormatException: For input string: "badparam" > at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) > at java.lang.Long.parseLong(Long.java:403) > at java.lang.Long.parseLong(Long.java:461) > at org.apache.hadoop.examples.PiEstimator.run(PiEstimator.java:241) > at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) > at org.apache.hadoop.examples.PiEstimator.main(PiEstimator.java:252) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68) > at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139) > at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:53) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at org.apache.hadoop.util.RunJar.main(RunJar.java:155) > at org.apache.hadoop.mapred.JobShell.run(JobShell.java:54) > at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) > at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) > at org.apache.hadoop.mapred.JobShell.main(JobShell.java:68) > exits with 0. > In my opinion, if a jar throws an exception that kills the program being run, and the developer doesn't catch the exception and do a sane exit with a exit code, hadoop should at least exit with a non-zero exit code. > As another example, while running a main class that exits with an exit code of 201, Hadoop will preserve the correct exit code: > public static void main(String[] args) throws Exception { > System.exit(201); > } > But when deliberately creating a null pointer exception, Hadoop exits with 0. > public static void main(String[] args) throws Exception { > Object o = null; > o.toString(); > System.exit(201); > } > This behaviour makes it very difficult, if not impossible, to use Hadoop programatically with tools such as HOD or non-Java data processing frameworks, since if a jar crashes with an unhandled exception, Hadoop doesn't inform the calling program in a well-bahaved way (polling stderr for output is not a very good way to detect application failure). > I'm not a Java programmer, so I don't know what the best code to signal failure would be. > Please let me know what other information I can include about my setup > Thanks. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.