Menu ▾ ▴

#63 WrapperManager checkThreads() calls stop() when it shouldn't

v3.1.1
open
API (14)
5
2004-10-08
2004-10-07
No

The checkThreads() method seems to think that it's a
good idea to force a restart for some reason.

I tried putting daemon threads in my app, I've tried
adding additional non-daemon threads in my app, neither
do any good-- therefore I have commented it out:
// in class: org.tanukisoftware.wrapper.WrapperManager
/**
* With a normal Java application, the JVM will exit
when all non-daemon
* threads have completed. This does not work
correctly with the wrapper
* because the connection thread is not a daemon.
It would also cause
* problems because the wrapper would not know
whether the exit had been
* intentional or not. This method takes care of
making sure that the
* JVM exits when it is supposed to and makes sure
that the Wrapper is
* propperly informed.
*/
private static void checkThreads()
{
int liveCount = getNonDaemonThreadCount();

// Depending on the JVM, there will always be one
(or zero) non-daemon thread alive.
// This thread is either the main thread which has
not yet completed, or a thread
// launched by java when the main thread
completes whose job is to wait around for
// all other non-daemon threads to complete. We
are overriding that thread here.
if ( liveCount <= m_systemThreadCount )
{
if ( m_debug )
{
m_out.println( "All non-daemon threads have
stopped. Exiting." );
}

// Exit normally
// NOT Exiting 'normally' -- there is some kind of
bug and the app is not running properly
//$$$WrapperManager.stop( 0 );
// Will not get here.
}
else
{
// There are daemons running, let the JVM
continue to run.
}
}

Discussion

  • Leif Mortenson

    Leif Mortenson - 2004-10-08
    • assigned_to: nobody --> mortenson
     
  • Leif Mortenson

    Leif Mortenson - 2004-10-08

    Logged In: YES
    user_id=228081

    The Wrapper includes that logic so that applications run
    with the Wrapper will function the same as they do when
    running standalone. A JVM will always shut itself down when
    the last of its non daemon threads have terminated. The
    Wrapper has its own non-daemon threads which interfere with
    this mechanism so it needs to do its own counting. This
    has been working for everyone for a long time, so I am
    curious as to what exactly is going on in your case.

    Could you go back to the unmodified version of the Wrapper,
    set the wrapper.debug=true property and then upload the
    resulting wrapper.log file to this issue?

    It should not be necessary for you to be making changes.

    Also, when all of the non-daemon threads have completed, the
    Wrapper will shutdown along with the JVM rather than
    restarting the JVM.

    Thanks,
    Leif

     

Log in to post a comment.