avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/util/datasource JdbcConnectionPool.java
Date Fri, 16 Mar 2001 20:18:59 GMT
bloritsch    01/03/16 12:18:59

  Modified:    src/java/org/apache/avalon/util/datasource
                        JdbcConnectionPool.java
  Log:
  Protect from infinite loop
  
  Revision  Changes    Path
  1.9       +17 -5     jakarta-avalon/src/java/org/apache/avalon/util/datasource/JdbcConnectionPool.java
  
  Index: JdbcConnectionPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/util/datasource/JdbcConnectionPool.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JdbcConnectionPool.java	2001/03/16 15:58:01	1.8
  +++ JdbcConnectionPool.java	2001/03/16 20:18:57	1.9
  @@ -26,7 +26,7 @@
    * thread to manage the number of SQL Connections.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.8 $ $Date: 2001/03/16 15:58:01 $
  + * @version CVS $Revision: 1.9 $ $Date: 2001/03/16 20:18:57 $
    */
   public class JdbcConnectionPool
       extends AbstractLoggable
  @@ -119,12 +119,12 @@
                   m_initThread.join();
               }
           }
  -        
  +
           if (m_disposed)
           {
               throw new IllegalStateException("You cannot get a Connection after the pool
is disposed");
           }
  -        
  +
           m_lock.lock(m_ready);
           Poolable obj = null;
           final int size;
  @@ -181,7 +181,7 @@
       public void run()
       {
           m_lock.lock(m_ready);
  -        while( m_ready.size() < m_max )
  +        for (int i = 0; i < m_max; i++)
           {
               try {
                   m_ready.add( createJdbcConnection() );
  @@ -189,8 +189,20 @@
                   getLogger().error( "Could not create connection to database", se );
               }
           }
  +
  +        if ((m_ready.size() < m_max) && (m_ready.size() > 0)) {
  +            while (m_ready.size() < m_max) {
  +                try {
  +                    m_ready.add( createJdbcConnection() );
  +                } catch (SQLException se) {
  +                    getLogger().error( "Could not create connection to database", se );
  +                }
  +            }
  +        }
   
  -        m_initialized = true;
  +        if (m_ready.size() > 0) {
  +            m_initialized = true;
  +        }
           m_lock.unlock(m_ready);
       }
   
  
  
  

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


Mime
View raw message