leosutic    2003/02/18 00:52:44

  Modified:    fortress/src/java/org/apache/avalon/fortress/impl/lookup
                        FortressServiceManager.java
  Log:
  Patch to cover for a bug in StaticBucketMap. The bug is filed as
  
      http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17139
  
  please see that URL for a description. The basic idea is to ensure that
  comparison with equals() among the lookup keys work.
  
  Revision  Changes    Path
  1.5       +24 -3     
avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/lookup/FortressServiceManager.java
  
  Index: FortressServiceManager.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/lookup/FortressServiceManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FortressServiceManager.java       15 Feb 2003 17:34:16 -0000      1.4
  +++ FortressServiceManager.java       18 Feb 2003 08:52:44 -0000      1.5
  @@ -131,7 +131,8 @@
           {
               final ComponentHandler handler = (ComponentHandler)result;
               final Object component = handler.get();
  -            m_used.put( component.toString(), handler );
  +            
  +            m_used.put( new ComponentKey(component), handler );
               return component;
           }
           catch( final ServiceException ce )
  @@ -162,7 +163,7 @@
   
       public void release( final Object component )
       {
  -        final ComponentHandler handler = (ComponentHandler)m_used.remove( 
component.toString() );
  +        final ComponentHandler handler = (ComponentHandler)m_used.remove( 
new ComponentKey(component) );
           if( null == handler )
           {
               if( null == m_parent )
  @@ -216,5 +217,25 @@
       {
           public String role;
           public String hint;
  +    }
  +    
  +    private final static class ComponentKey
  +    {
  +        private final Object component;
  +        
  +        public ComponentKey( Object component )
  +        {
  +            this.component = component;
  +        }
  +        
  +        public boolean equals( Object other )
  +        {
  +            return (other instanceof ComponentKey) && ((ComponentKey) 
other).component == this.component;
  +        }
  +        
  +        public int hashCode()
  +        {
  +            return component.hashCode();
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to