db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Van Couvering <David.Vancouver...@Sun.COM>
Subject Re: [jira] Commented: (DERBY-214) Remove System.exit() calls from the DB2jServerImpl.java
Date Thu, 28 Apr 2005 13:23:27 GMT
We could add an argument that indicates whether or not the main program 
should call System.exit() or just return.  It's very valuable to have a 
non-zero exit status when calling a command from the command-line, for 
better scriptability...

e.g. "-noSysExit"

But I think what would be better is if applications like Eclipse don't 
call main() but call the execute() method, which only throws an 
exception.   This same issue exists for all the Derby tools, and it 
would be good if we had a policy that didn't require a "-noSysExit" 
option on every command.

I can add an execute() method to NetworkServerControl so it's on the 
same class as the main() method.


Kathey Marsden wrote:

> David Van Couvering (JIRA) wrote:
>> Is it OK for NetworkServerControl to call System.exit, or does that need to throw
an exception as well?
>>The technique I usually do for a utility that I want callable by another class as
well as executable from the command line is for the main() routine to delegate to another
public method which throws exceptions and doesn't call System.exit().  Then the main() routine
catches any exceptions and calls System.exit(1) if there is an exception or System.exit(0)
if there isn't one.  Then classes call the other public method and main() is only used from
the command-line.
> The execute() method which is the one with the System.exit is only
> called by NetworkServerControl.main()  so I guess it is the exit even
> from main that is causing a problem with eclipse.  For the exit(0),  I
> guess we could just return.  For the exit(1) case I am not entirely sure
> what  is appropriate.    Maybe  main should just throw the exception
> then we get an error exit but the calling program won't exit completely.
> Rajesh filed the original case when he had a problem with eclipse
> exiting completely when he tried to use the main method from within
> eclipse.  Rajesh could you confirm that  that is the case?
> Kathey

View raw message