[jboss-cvs] JBossAS SVN: r110448 - branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 26 04:58:01 EST 2011
Author: raggz
Date: 2011-01-26 04:58:01 -0500 (Wed, 26 Jan 2011)
New Revision: 110448
Modified:
branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
Log:
This is a fix for JIRA JBPAPP-5292 it going into this special patch JBPAPP-5820.
Modified: branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
===================================================================
--- branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java 2011-01-26 03:53:51 UTC (rev 110447)
+++ branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java 2011-01-26 09:58:01 UTC (rev 110448)
@@ -550,17 +550,33 @@
ManagedConnection mc = open(subject);
XAResource xaResource = null;
+ Object connection = null;
try
{
xaResource = mc.getXAResource();
+ connection = openConnection(mc, subject);
}
catch (ResourceException reconnect)
{
+ closeConnection(connection);
+ connection = null;
close(mc);
mc = open(subject);
xaResource = mc.getXAResource();
}
+ finally
+ {
+ boolean forceDestroy = closeConnection(connection);
+ connection = null;
+ if (forceDestroy)
+ {
+ close(mc);
+ mc = open(subject);
+ xaResource = mc.getXAResource();
+ }
+ }
+
try
{
ObjectName on = new ObjectName(connectionManager);
@@ -774,6 +790,66 @@
mc = null;
}
+
+ /**
+ * Open a connection
+ * @param mc The managed connection
+ * @param s The subject
+ * @return The connection handle
+ * @exception ResourceException Thrown in case of an error
+ */
+ private Object openConnection(ManagedConnection mc, Subject s) throws ResourceException
+ {
+ return mc.getConnection(s, null);
+ }
+
+ /**
+ * Close a connection
+ * @param c The connection
+ * @return Should the managed connection be forced closed
+ */
+ private boolean closeConnection(Object c)
+ {
+ if (c != null)
+ {
+ if (c instanceof javax.resource.cci.Connection)
+ {
+ try
+ {
+ javax.resource.cci.Connection cci = (javax.resource.cci.Connection)c;
+ cci.close();
+ }
+ catch (ResourceException ire)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Error during recovery connection close", ire);
+ }
+ }
+ else
+ {
+ try
+ {
+ Method method = c.getClass().getMethod("close", new Class[0]);
+ method.setAccessible(true);
+ method.invoke(c, new Object[0]);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ log.warn("No close() method defined on connection interface. Destroying managed connection to clean-up", nsme);
+ return true;
+ }
+ catch (Throwable t)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Error during recovery connection close", t);
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
public void setManagedConnectionFactoryAttribute(String name, Class clazz, Object value)
{
More information about the jboss-cvs-commits
mailing list