You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/03/25 22:34:02 UTC

cvs commit: avalon-excalibur/pool/src/java/org/apache/avalon/excalibur/pool DefaultPool.java

bloritsch    2003/03/25 13:34:02

  Modified:    component default.properties
               datasource/src/java/org/apache/avalon/excalibur/datasource
                        JdbcConnectionPool.java
               datasource/src/test/org/apache/avalon/excalibur/datasource/test
                        DataSourceJdbcTestCase.xtest
               fortress/src/java/org/apache/avalon/fortress/impl/role
                        ServiceRoleManager.java
               pool     default.properties
               pool/src/java/org/apache/avalon/excalibur/pool
                        DefaultPool.java
  Log:
  update to pool to protect against index out of bounds exception
  
  Revision  Changes    Path
  1.27      +2 -2      avalon-excalibur/component/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/component/default.properties,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- default.properties	7 Mar 2003 19:35:47 -0000	1.26
  +++ default.properties	25 Mar 2003 21:34:01 -0000	1.27
  @@ -45,10 +45,10 @@
   excalibur-i18n.jar=${excalibur-i18n.lib}/excalibur-i18n-1.0.jar
   
   # ----- Doug Lea's Concurrent Utils, version 1.3 or later -----
  -util.concurrent.jar=${basedir}/../event/lib/util.concurrent-1.3.1.jar
  +util.concurrent.jar=${basedir}/../lib/util.concurrent-1.3.1.jar
   
   # ----- Commons collections, version 2.1 or later -----
  -commons-collections.jar=${basedir}/../event/lib/commons-collections-2.1.jar
  +commons-collections.jar=${basedir}/../lib/commons-collections-2.1.jar
   
   # ----- Excalibur instrument -----
   excalibur-instrument.home=${basedir}/../instrument/dist
  
  
  
  1.23      +9 -14     avalon-excalibur/datasource/src/java/org/apache/avalon/excalibur/datasource/JdbcConnectionPool.java
  
  Index: JdbcConnectionPool.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/datasource/src/java/org/apache/avalon/excalibur/datasource/JdbcConnectionPool.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JdbcConnectionPool.java	25 Mar 2003 20:01:48 -0000	1.22
  +++ JdbcConnectionPool.java	25 Mar 2003 21:34:01 -0000	1.23
  @@ -50,8 +50,6 @@
   package org.apache.avalon.excalibur.datasource;
   
   import java.sql.Connection;
  -import java.util.HashSet;
  -import java.util.Iterator;
   
   import org.apache.avalon.excalibur.pool.DefaultPoolController;
   import org.apache.avalon.excalibur.pool.HardResourceLimitingPool;
  @@ -76,7 +74,7 @@
       private final boolean m_autoCommit;
       private boolean m_noConnections;
       private long m_wait = -1;
  -    private HashSet m_waitingThreads = new HashSet();
  +    private Object m_spinLock = new Object();
   
       public JdbcConnectionPool( final JdbcConnectionFactory factory, 
                                  final DefaultPoolController controller, 
  @@ -127,15 +125,15 @@
               long endTime = curMillis + m_wait;
               while( ( null == conn ) && ( curMillis < endTime ) )
               {
  -                Thread thread = Thread.currentThread();
  -                m_waitingThreads.add( thread );
  -
                   try
                   {
  -                    curMillis = System.currentTimeMillis();
                       unlock();
  +                    curMillis = System.currentTimeMillis();
   
  -                    thread.wait( endTime - curMillis );
  +                    synchronized(m_spinLock)
  +                    {
  +                        m_spinLock.wait( endTime - curMillis );
  +                    }
                   }
                   finally
                   {
  @@ -229,12 +227,9 @@
       public void put( Poolable obj )
       {
           super.put( obj );
  -        Iterator i = m_waitingThreads.iterator();
  -        while( i.hasNext() )
  +        synchronized(m_spinLock)
           {
  -            Object thread = i.next();
  -            thread.notify();
  -            i.remove();
  +            m_spinLock.notifyAll();
           }
       }
   
  
  
  
  1.6       +1 -3      avalon-excalibur/datasource/src/test/org/apache/avalon/excalibur/datasource/test/DataSourceJdbcTestCase.xtest
  
  Index: DataSourceJdbcTestCase.xtest
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/datasource/src/test/org/apache/avalon/excalibur/datasource/test/DataSourceJdbcTestCase.xtest,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DataSourceJdbcTestCase.xtest	25 Mar 2003 21:02:53 -0000	1.5
  +++ DataSourceJdbcTestCase.xtest	25 Mar 2003 21:34:01 -0000	1.6
  @@ -53,9 +53,7 @@
     -->
     <components>
       <datasource logger="test">
  -      <pool-controller min="5" max="10" timeout="1000">
  -         <keep-alive disable="true"/>
  -      </pool-controller>
  +      <pool-controller min="5" max="10"/>
         <driver>org.hsqldb.jdbcDriver</driver>
         <dburl>jdbc:hsqldb:test</dburl>
         <user>SA</user>
  
  
  
  1.6       +8 -2      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/role/ServiceRoleManager.java
  
  Index: ServiceRoleManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/role/ServiceRoleManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServiceRoleManager.java	25 Mar 2003 01:36:15 -0000	1.5
  +++ ServiceRoleManager.java	25 Mar 2003 21:34:01 -0000	1.6
  @@ -197,7 +197,6 @@
               if( shortName.length() == 0 )
               {
                   matcher.appendReplacement( shortName, "$1" );
  -                ;
               }
               else
               {
  @@ -229,7 +228,14 @@
           {
               String role = (String)it.next();
               getLogger().debug( "Adding service: " + role );
  -            setupImplementations( role );
  +            try
  +            {
  +                setupImplementations( role );
  +            }
  +            catch( Exception e )
  +            {
  +                getLogger().debug( "Specified service '" + role + "' is not available", e );
  +            }
           }
       }
   
  
  
  
  1.20      +1 -1      avalon-excalibur/pool/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/pool/default.properties,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- default.properties	10 Mar 2003 15:02:27 -0000	1.19
  +++ default.properties	25 Mar 2003 21:34:01 -0000	1.20
  @@ -22,7 +22,7 @@
   avalon-framework.jar=${avalon-framework.lib}/avalon-framework.jar
   
   # ----- Commons collections, version 2.1 or later -----
  -commons-collections.jar=${basedir}/../event/lib/commons-collections-2.1.jar
  +commons-collections.jar=${basedir}/../lib/commons-collections-2.1.jar
   
   # --------------------------------------------------
   #                OPTIONAL LIBRARIES
  
  
  
  1.4       +4 -3      avalon-excalibur/pool/src/java/org/apache/avalon/excalibur/pool/DefaultPool.java
  
  Index: DefaultPool.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/pool/src/java/org/apache/avalon/excalibur/pool/DefaultPool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultPool.java	20 Feb 2003 17:09:24 -0000	1.3
  +++ DefaultPool.java	25 Mar 2003 21:34:02 -0000	1.4
  @@ -157,6 +157,7 @@
           }
   
           m_mutex.acquire();
  +
           try
           {
               if( m_ready.size() == 0 )
  @@ -207,7 +208,7 @@
       {
           if( !m_initialized )
           {
  -            final String message = "You cannot get a Poolable before " +
  +            final String message = "You cannot put a Poolable before " +
                   "the pool is initialized";
               throw new IllegalStateException( message );
           }
  @@ -222,7 +223,7 @@
               m_mutex.acquire();
               try
               {
  -                m_active.remove( m_active.indexOf( obj ) );
  +                m_active.remove(obj);
   
                   if( getLogger().isDebugEnabled() )
                   {
  
  
  

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