avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends CLIMain.java
Date Tue, 28 May 2002 11:52:21 GMT
leif        02/05/28 04:52:21

  Modified:    src/java/org/apache/avalon/phoenix/frontends CLIMain.java
  Log:
  Fix a problem where the shutdown method was recursively calling the Wrapper
  stop method.
  
  Revision  Changes    Path
  1.39      +37 -27    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLIMain.java
  
  Index: CLIMain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLIMain.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- CLIMain.java	22 May 2002 12:54:18 -0000	1.38
  +++ CLIMain.java	28 May 2002 11:52:21 -0000	1.39
  @@ -58,6 +58,8 @@
       private int m_exitCode;
   
       private ShutdownHook m_hook;
  +    
  +    private boolean m_shuttingDown;
   
       /**
        * Main entry point.
  @@ -260,34 +262,42 @@
        */
       public synchronized void shutdown()
       {
  -        //Null hook so it is not tried to be removed
  -        //when we are shutting down. (Attempting to remove
  -        //hook during shutdown raises an exception).
  -        m_hook = null;
  -
  -        if( null != m_embeddor )
  -        {
  -            final String message = REZ.getString( "main.exit.notice" );
  -            System.out.println( message );
  -            System.out.flush();
  -
  -            try
  -            {
  -                ContainerUtil.shutdown( m_embeddor );
  -            }
  -            catch( final Throwable throwable )
  -            {
  -                handleException( throwable );
  -            }
  -            finally
  -            {
  -                m_embeddor = null;
  -            }
  +        // Depending on how the shutdown process is initiated, it is possible
  +        //  that the shutdown() method can be recursively called from within
  +        //  the call to notifyObservers below.
  +        if ( !m_shuttingDown )
  +        {
  +            m_shuttingDown = true;
  +            
  +            //Null hook so it is not tried to be removed
  +            //when we are shutting down. (Attempting to remove
  +            //hook during shutdown raises an exception).
  +            m_hook = null;
  +    
  +            if( null != m_embeddor )
  +            {
  +                final String message = REZ.getString( "main.exit.notice" );
  +                System.out.println( message );
  +                System.out.flush();
  +    
  +                try
  +                {
  +                    ContainerUtil.shutdown( m_embeddor );
  +                }
  +                catch( final Throwable throwable )
  +                {
  +                    handleException( throwable );
  +                }
  +                finally
  +                {
  +                    m_embeddor = null;
  +                }
  +            }
  +    
  +            // Notify any observers that Phoenix is shutting down
  +            setChanged();
  +            notifyObservers( "shutdown" );
           }
  -
  -        // Notify any observers that Phoenix is shutting down
  -        setChanged();
  -        notifyObservers( "shutdown" );
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message