[jboss-cvs] JBossAS SVN: r68460 - branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 20 12:02:37 EST 2007
Author: adrian at jboss.org
Date: 2007-12-20 12:02:37 -0500 (Thu, 20 Dec 2007)
New Revision: 68460
Modified:
branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
Log:
[JBAS-5095] - Avoid duplicate connections getting into the pool due to buggy connection managers. Log a warning when it happens.
Modified: branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java 2007-12-20 16:54:27 UTC (rev 68459)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java 2007-12-20 17:02:37 UTC (rev 68460)
@@ -312,17 +312,21 @@
public void returnConnection(ConnectionListener cl, boolean kill)
{
- if (cl.getState() == ConnectionListener.DESTROYED)
+ synchronized (cls)
{
- log.trace("ManagedConnection is being returned after it was destroyed" + cl);
- if (cl.hasPermit())
+ if (cl.getState() == ConnectionListener.DESTROYED)
{
- // release semaphore
- cl.grantPermit(false);
- permits.release();
+ if (trace)
+ log.trace("ManagedConnection is being returned after it was destroyed" + cl);
+ if (cl.hasPermit())
+ {
+ // release semaphore
+ cl.grantPermit(false);
+ permits.release();
+ }
+
+ return;
}
-
- return;
}
if (trace)
@@ -337,12 +341,12 @@
kill = true;
}
- // We need to destroy this one
- if (cl.getState() == ConnectionListener.DESTROY)
- kill = true;
-
synchronized (cls)
{
+ // We need to destroy this one
+ if (cl.getState() == ConnectionListener.DESTROY || cl.getState() == ConnectionListener.DESTROYED)
+ kill = true;
+
checkedOut.remove(cl);
// This is really an error
@@ -359,14 +363,17 @@
// a connection error occurred.
// This could happen while the connection is not checked out.
// e.g. JMS can do this via an ExceptionListener on the connection.
- // I have twice had to reinstate this line of code, PLEASE DO NOT REMOTE IT!
+ // I have twice had to reinstate this line of code, PLEASE DO NOT REMOVE IT!
cls.remove(cl);
}
// return to the pool
else
{
cl.used();
- cls.add(cl);
+ if (cls.contains(cl) == false)
+ cls.add(cl);
+ else
+ log.warn("Attempt to return connection twice (ignored): " + cl, new Throwable("STACKTRACE"));
}
if (cl.hasPermit())
@@ -383,7 +390,6 @@
log.trace("Destroying returned connection " + cl);
doDestroy(cl);
}
-
}
public void flush()
Modified: branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java 2007-12-20 16:54:27 UTC (rev 68459)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java 2007-12-20 17:02:37 UTC (rev 68460)
@@ -628,7 +628,7 @@
InternalManagedConnectionPool mcp = (InternalManagedConnectionPool) cl.getContext();
mcp.returnConnection(cl, kill);
if (traceEnabled)
- dump("Returning connection to pool " + cl);
+ dump("Returned connection to pool " + cl);
}
/**
More information about the jboss-cvs-commits
mailing list