leif 2003/07/17 19:39:06
Modified: datasource/src/java/org/apache/avalon/excalibur/datasource
AbstractJdbcConnection.java
Log:
Fix a problem where connections closed by the server were leading to a leak that
would eventually cause blocking pools to think that all connections were allocated
and block forever.
Revision Changes Path
1.30 +21 -13
avalon-excalibur/datasource/src/java/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java
Index: AbstractJdbcConnection.java
===================================================================
RCS file:
/home/cvs/avalon-excalibur/datasource/src/java/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- AbstractJdbcConnection.java 11 Jun 2003 17:40:21 -0000 1.29
+++ AbstractJdbcConnection.java 18 Jul 2003 02:39:06 -0000 1.30
@@ -242,22 +242,30 @@
public void close()
throws SQLException
{
- // Always mark the time the connection was placed back in the pool
- // as its last used time.
- m_lastUsed = System.currentTimeMillis();
-
+ // IMPORTANT - never simply call dispose within this method. The
+ // pool will have no way of knowing that the connection was disposed
+ // and blocking pools will eventually run out of resources thinking
+ // that all of the connections are in use.
try
{
- clearAllocatedStatements();
- m_connection.clearWarnings();
- m_pool.put( (Poolable)m_proxy );
+ // Always mark the time the connection was placed back in the pool
+ // as its last used time.
+ m_lastUsed = System.currentTimeMillis();
+
+ try
+ {
+ clearAllocatedStatements();
+ m_connection.clearWarnings();
+ }
+ catch( SQLException se )
+ {
+ // This can be ignored here.
+ }
}
- catch( SQLException se )
+ finally
{
- // gets rid of connections that throw SQLException during
- // clean up
- getLogger().error( "Connection could not be recycled", se );
- this.dispose();
+ // Always put the connection back into the pool
+ m_pool.put( (Poolable)m_proxy );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]