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-excalibur/component/src/java/org/apache/avalon/excalibur/component ExcaliburComponentManager.java ExcaliburComponentSelector.java
Date Wed, 10 Apr 2002 05:38:43 GMT
leif        02/04/09 22:38:43

  Modified:    component/src/java/org/apache/avalon/excalibur/component
                        ExcaliburComponentManager.java
                        ExcaliburComponentSelector.java
  Log:
  Fix a bad synchronization problem which was causing poolable resources to be
  lost once in a while.  Recycle was not being called in these cases.
  
  Revision  Changes    Path
  1.2       +20 -11    jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java
  
  Index: ExcaliburComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburComponentManager.java	4 Apr 2002 05:09:02 -0000	1.1
  +++ ExcaliburComponentManager.java	10 Apr 2002 05:38:43 -0000	1.2
  @@ -32,7 +32,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/04/04 05:09:02 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/04/10 05:38:43 $
    * @since 4.0
    */
   public class ExcaliburComponentManager
  @@ -496,6 +496,7 @@
       {
           if( null == component )
           {
  +            getLogger().warn( "Attempted to release a null component." );
               return;
           }
   
  @@ -508,6 +509,19 @@
   
           if( null != handler )
           {
  +            // ThreadSafe components will always be using a ThreadSafeComponentHandler,
  +            //  they will only have a single entry in the m_componentMapping map which
  +            //  should not be removed until the ComponentManager is disposed.  All
  +            //  other components have an entry for each instance which should be
  +            //  removed.
  +            if( !( handler instanceof ThreadSafeComponentHandler ) )
  +            {
  +                // Remove the component before calling put.  This is critical to avoid
the
  +                //  problem where another thread calls put on the same component before
  +                //  remove can be called.
  +                m_componentMapping.remove( component );
  +            }
  +            
               try
               {
                   handler.put( component );
  @@ -519,20 +533,15 @@
                       getLogger().debug( "Error trying to release component.", e );
                   }
               }
  -
  -            // ThreadSafe components will always be using a ThreadSafeComponentHandler,
  -            //  they will only have a single entry in the m_componentMapping map which
  -            //  should not be removed until the ComponentManager is disposed.  All
  -            //  other components have an entry for each instance which should be
  -            //  removed.
  -            if( !( handler instanceof ThreadSafeComponentHandler ) )
  -            {
  -                m_componentMapping.remove( component );
  -            }
           }
           else if( null != m_parentManager )
           {
               m_parentManager.release( component );
  +        }
  +        else
  +        {
  +            getLogger().warn( "Attempted to release a " + component.getClass().getName()
+
  +                " but its handler could not be located." );
           }
       }
   
  
  
  
  1.2       +18 -4     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java
  
  Index: ExcaliburComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburComponentSelector.java	4 Apr 2002 05:09:02 -0000	1.1
  +++ ExcaliburComponentSelector.java	10 Apr 2002 05:38:43 -0000	1.2
  @@ -33,7 +33,7 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/04/04 05:09:02 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/04/10 05:38:43 $
    * @since 4.0
    */
   public class ExcaliburComponentSelector
  @@ -409,6 +409,7 @@
       {
           if( null == component )
           {
  +            getLogger().warn( "Attempted to release a null component." );
               return;
           }
   
  @@ -417,9 +418,24 @@
   
           if( null == handler )
           {
  +            getLogger().warn( "Attempted to release a " + component.getClass().getName()
+
  +                " but its handler could not be located." );
               return;
           }
  -
  +        
  +        // ThreadSafe components will always be using a ThreadSafeComponentHandler,
  +        //  they will only have a single entry in the m_componentMapping map which
  +        //  should not be removed until the ComponentManager is disposed.  All
  +        //  other components have an entry for each instance which should be
  +        //  removed.
  +        if( !( handler instanceof ThreadSafeComponentHandler ) )
  +        {
  +            // Remove the component before calling put.  This is critical to avoid the
  +            //  problem where another thread calls put on the same component before
  +            //  remove can be called.
  +            m_componentMapping.remove( component );
  +        }
  +        
           try
           {
               handler.put( component );
  @@ -431,8 +447,6 @@
                   getLogger().debug( "Error trying to release component", e );
               }
           }
  -
  -        m_componentMapping.remove( component );
       }
   
       /**
  
  
  

--
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