You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Owen O'Malley (JIRA)" <ji...@apache.org> on 2006/06/27 08:15:30 UTC

[jira] Created: (HADOOP-327) ToolBase calls System.exit

ToolBase calls System.exit
--------------------------

         Key: HADOOP-327
         URL: http://issues.apache.org/jira/browse/HADOOP-327
     Project: Hadoop
        Type: Bug

  Components: util  
    Versions: 0.4.0    
    Reporter: Owen O'Malley
 Assigned to: Hairong Kuang 
     Fix For: 0.4.0


The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Updated: (HADOOP-327) ToolBase calls System.exit

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-327?page=all ]

Doug Cutting updated HADOOP-327:
--------------------------------

    Fix Version: 0.5.0
                     (was: 0.4.0)

> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0

>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Resolved: (HADOOP-327) ToolBase calls System.exit

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-327?page=all ]
     
Doug Cutting resolved HADOOP-327:
---------------------------------

    Resolution: Fixed

I just committed this.  Thanks, Hairong.

David: you are right, implementations of the Tool interface can throw more precise exceptions.

> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0
>  Attachments: exit.patch, exit.patch
>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Updated: (HADOOP-327) ToolBase calls System.exit

Posted by "Hairong Kuang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-327?page=all ]

Hairong Kuang updated HADOOP-327:
---------------------------------

    Attachment: exit.patch

The patch removes System.exit from ToolBase and adjusts the interface of method "run" to throw IOException.

> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0
>  Attachments: exit.patch
>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Commented: (HADOOP-327) ToolBase calls System.exit

Posted by "David Bowen (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-327?page=comments#action_12420335 ] 

David Bowen commented on HADOOP-327:
------------------------------------


I think it is better to be as explicit as possible about which (checked) Exceptions your main() routine is not handling.  It is useful to the reader to know that the only checked exception that can be thrown is an IOException.  This doesn't require any additional code, and in any case readability is more important than saving a line or two.



> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0
>  Attachments: exit.patch
>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Updated: (HADOOP-327) ToolBase calls System.exit

Posted by "Hairong Kuang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-327?page=all ]

Hairong Kuang updated HADOOP-327:
---------------------------------

    Attachment: exit.patch

Here is the new patch reflecting Doug's suggestion. In addition to removing System.exit, I changed the main function of DFSShell, JobClient, and CopyFiles to throw Exception instead of IOException.

> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0
>  Attachments: exit.patch, exit.patch
>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Commented: (HADOOP-327) ToolBase calls System.exit

Posted by "David Bowen (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-327?page=comments#action_12420372 ] 

David Bowen commented on HADOOP-327:
------------------------------------


Agreed that the interface method needs to throw Exception.  I thought that you were disagreeing with the changes to the more specific IOException in the implementing classes also.


> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0
>  Attachments: exit.patch
>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Commented: (HADOOP-327) ToolBase calls System.exit

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-327?page=comments#action_12420276 ] 

Doug Cutting commented on HADOOP-327:
-------------------------------------

I agree with removing the call to exit(), but I don't see the need to change the exception.

To my thinking, this replaces the standard main() signature:

public static void main(String[] args) throws Exception {
  ...
}

Folks frequently write main() to not throw anything, and then catch exceptions and print the stacktrace.  This just makes the code bigger, since the JVM already prints the stack trace when a main() throws an exception.  It also makes it harder to call the main() programatically (which is ocassionally useful) since you'll have no idea whether it has somehow failed.  So this is why I argue that main() routines should throw Exception, and analagously, why our replacement should do the same.  Otherwise we'll just have folks catching other exceptions and repackaging them in IOException, adding pointless code.


> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0
>  Attachments: exit.patch
>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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


[jira] Commented: (HADOOP-327) ToolBase calls System.exit

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-327?page=comments#action_12420348 ] 

Doug Cutting commented on HADOOP-327:
-------------------------------------

But at issue here is not a particular main(), but an interface for main()-like methods.  So we cannot know which specific exceptions might be thrown.

> ToolBase calls System.exit
> --------------------------
>
>          Key: HADOOP-327
>          URL: http://issues.apache.org/jira/browse/HADOOP-327
>      Project: Hadoop
>         Type: Bug

>   Components: util
>     Versions: 0.4.0
>     Reporter: Owen O'Malley
>     Assignee: Hairong Kuang
>      Fix For: 0.5.0
>  Attachments: exit.patch
>
> The new ToolBase class calls System.exit when the main routine finishes. That will break if the application uses threads that need to finish before the jvm exits. The normal semantics is that the program doesn't finish execution until all of the non-daemon threads exit (including the main one) and System.exit should never be called except for critical errors.

-- 
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