[Jboss-cvs] JBossAS SVN: r55016 - branches/Branch_4_0/connector/src/main/org/jboss/resource/adapter/jdbc/xa

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 1 23:39:09 EDT 2006


Author: weston.price at jboss.com
Date: 2006-08-01 23:39:08 -0400 (Tue, 01 Aug 2006)
New Revision: 55016

Modified:
   branches/Branch_4_0/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java
Log:
[JBAS-3336]Destroy a connection where XA enlistment fails and do not return the 
connection to the pool.

Modified: branches/Branch_4_0/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java
===================================================================
--- branches/Branch_4_0/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java	2006-08-02 02:44:34 UTC (rev 55015)
+++ branches/Branch_4_0/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java	2006-08-02 03:39:08 UTC (rev 55016)
@@ -39,6 +39,8 @@
  * 
  * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks </a>
  * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:weston.price at jboss.com">Weston Price</a>
+ * 
  * @version $Revision$
  */
 public class XAManagedConnection extends BaseWrapperManagedConnection implements XAResource
@@ -114,7 +116,23 @@
       {
          getLog().warn("Error setting state ", e);
       }
-      xaResource.start(xid, flags);
+      try
+      {
+         xaResource.start(xid, flags);
+         
+      }catch(XAException e)
+      {
+         //JBAS-3336 Connections that fail in enlistment should not be returned
+         //to the pool
+         if(isFailedXA(e.errorCode))
+         {
+            getLog().error("Start transaction failed for " + this);
+            broadcastConnectionError(e);  
+         }
+         
+         throw e;
+      }
+      
       synchronized (stateLock)
       {
          currentXid = xid;
@@ -185,7 +203,13 @@
    {
       return xaResource.setTransactionTimeout(seconds);
    }
-
+   
+   private boolean isFailedXA(int errorCode)
+   {
+      
+      return (errorCode == XAException.XAER_RMERR || errorCode == XAException.XAER_RMFAIL);      
+   }
+   
    Properties getProps()
    {
       return props;




More information about the jboss-cvs-commits mailing list