Hi Martin,

Thanks for the quick review.

Users should only add their shutdown hooks via the System.addShutdownHook() method. java.lang.Shutdown is an implementation class for registering internal hooks besides application shutdown hooks - including the shutdown hook for Console and DeleteOnExitHook. Applications should not use the Shutdown#add method.
How do you manage the order of independently developed shutdown hooks?
I assume you're concerned with application shutdown hooks. The order will be managed by ApplicationShutdownHooks (in the order when a hook is added). Are you concerned with other use of Shutdown#add?
Mandy

Martin Buchholz wrote:
Thanks for your quick response on this.

A quick review says: looks good to me.
Someone should give it a more thorough review.
-----
The solution of allowing shutdown hooks of a particular type to be added
during shutdown before that slot is reached is clever.

I'm sure there are use cases for users to be able to do the same thing
with their own shutdown hooks, but it would be tricky to provide such
a facility in a clean way.  How do you manage the order of independently
developed shutdown hooks?  Probably still a research problem.

-----

the last shutdown hook to invoke.
=>
the last shutdown hook to be invoked.

Martin

On Fri, Apr 17, 2009 at 15:05, Mandy Chung <mandy.ch...@sun.com> wrote:
6829503: addShutdownHook fails if called after shutdown has commenced.

Webrev at:
 http://cr.openjdk.java.net/~mchung/6829503/webrev.00/

I change the Shutdown#add method to take the registerShutdownInProgress
parameter.  If set to true, the specified shutdown hook is allowed to be
registered while shutdown is in progress.  The method will throw
IllegalStateException if the shutdown process already passes this slot.
DeleteOnExitHook is the last shutdown hook to be invoked and it will not be
invoked until all application shutdown hooks finish (see
ApplicationShutdownHooks.runHooks()).  So any file added to the delete on
exit list by the application shutdown hooks will be handled by the
DeleteOnExitHook.

The LoggingDeadlock2.java test passes with this fix.  I also add a new jtreg
test to exercise the Console and DeleteOnExitHook being initialized during
application shutdown.

Alan,
 I considered your suggestion to make Shutdown#add method to return a
boolean instead of checking the state.  I am concerned that if the caller
didn't check the return value and handle properly, it would be harder to
catch the problem.  So I keep it to check the state and throw
IllegalStateException.

Thanks
Mandy


Reply via email to