Menu ▾ ▴

#184 remove wrapper shutdownhook fails

v3.2.3
open-fixed
None
5
2008-02-04
2007-09-21
No

WrapperManager.privilegedStopInner is sometimes called twice, in my logs I see text about an "offending System.exit()".

The Problem:
WrapperManager.shutdownJVM() tries to remove the shutdown hooks, but fails with a IllegalStateException, because the shutdown sequence has already been initiated. During shutdown you cannot add or remove shutdown hooks.
So the hooks are called twice and privilegedStopInner() assumes it must be a system.exit().

Why is the shutdown sequence already initiated when trying to removeShutdownHook()?

It seems that at end of shutdown procedure the "WrapperListener_stop_runner" is the only remaining "non daemon" thread in system, all other threads exited. The doc says: the system initiates the shutdown sequence as soon as the last "non daemon" thread exits. This is when "WrapperListener_stop_runner" exits. From this moment on you cannot remove shutdown hooks anymore (IllegalStateException). WrapperManager gets this exception when calling it from shutdownJVM() because at this very moment the shutdown sequence was already initiated.

Proposal for a solution:
Place the removeShutdownHook() in the "Stop_Runner" thread. "Stop_Runner" should call this before it stops.

hth

this one was hard to find

Discussion

  • Leif Mortenson

    Leif Mortenson - 2008-02-04

    Logged In: YES
    user_id=228081
    Originator: NO

    Hubert,
    Thank you for taking the time to track this problem down. I moved the deregistration of the shutdown hook a little earlier that you suggested but that should solve the problems you were seeing.

    The fix will be included in the 3.3.0 release.

    Cheers.
    Leif

     
  • Leif Mortenson

    Leif Mortenson - 2008-02-04
    • milestone: --> v3.2.3
    • assigned_to: nobody --> mortenson
    • status: open --> open-fixed
     

Log in to post a comment.