Author: kwright
Date: Mon Feb 4 16:50:25 2013
New Revision: 1442171
URL: http://svn.apache.org/viewvc?rev=1442171&view=rev
Log:
More painless implementation of connection tracking, part of CONNECTORS-638.
Modified:
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/WrappedConnection.java
Modified:
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java?rev=1442171&r1=1442170&r2=1442171&view=diff
==============================================================================
---
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java
(original)
+++
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java
Mon Feb 4 16:50:25 2013
@@ -66,6 +66,11 @@ public class ConnectionPool
public WrappedConnection getConnection()
throws SQLException, InterruptedException
{
+ Exception instantiationException;
+ if (debug)
+ instantiationException = new Exception("Possibly leaked db connection");
+ else
+ instantiationException = null;
while (true)
{
synchronized (this)
@@ -76,7 +81,7 @@ public class ConnectionPool
throw new InterruptedException("Pool already closed");
Connection rval = freeConnections[--freePointer];
freeConnections[freePointer] = null;
- WrappedConnection rval3 = new WrappedConnection(this,rval);
+ WrappedConnection rval3 = new
WrappedConnection(this,rval,instantiationException);
if (debug)
outstandingConnections.add(rval3);
return rval3;
@@ -89,7 +94,7 @@ public class ConnectionPool
Logging.db.warn("Out of db connections, list of outstanding ones
follows.");
for (int i = 0; i < outstandingConnections.size(); i++)
{
- outstandingConnections.get(i).printAllocationStackTrace();
+ Logging.db.warn("Found a possibly leaked db
connection",outstandingConnections.get(i).getInstantiationException());
}
}
// Wait until kicked; we hope something will free up...
@@ -116,7 +121,7 @@ public class ConnectionPool
if (rval2 == null)
activeConnections--;
}
- WrappedConnection rval4 = new WrappedConnection(this,rval2);
+ WrappedConnection rval4 = new
WrappedConnection(this,rval2,instantiationException);
if (debug)
{
synchronized (this)
Modified:
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/WrappedConnection.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/WrappedConnection.java?rev=1442171&r1=1442170&r2=1442171&view=diff
==============================================================================
---
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/WrappedConnection.java
(original)
+++
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/WrappedConnection.java
Mon Feb 4 16:50:25 2013
@@ -35,9 +35,15 @@ public class WrappedConnection
/** Constructor */
public WrappedConnection(ConnectionPool owner, Connection connection)
{
+ this(owner,connection,null);
+ }
+
+ /** Constructor */
+ public WrappedConnection(ConnectionPool owner, Connection connection,
Exception instantiationException)
+ {
this.owner = owner;
this.connection = connection;
- this.instantiationException = new Exception("Possibly leaked db
conneciton");
+ this.instantiationException = instantiationException;
}
/** Get the JDBC connection object.
@@ -55,11 +61,13 @@ public class WrappedConnection
this.connection = null;
}
- /** Print allocation information */
- public void printAllocationStackTrace()
+ /** Get instantiation exception.
+ */
+ public Exception getInstantiationException()
{
- Logging.db.warn("Found a possibly leaked db
connection",instantiationException);
+ return instantiationException;
}
+
}