[jboss-svn-commits] JBL Code SVN: r36766 - in labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA: jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Mar 2 04:48:00 EST 2011


Author: jhalliday
Date: 2011-03-02 04:48:00 -0500 (Wed, 02 Mar 2011)
New Revision: 36766

Modified:
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
Backport XAResource recovery scan correlation fix. JBTM-827



Property changes on: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA
___________________________________________________________________
Added: svn:mergeinfo
   + /labs/jbosstm/trunk/ArjunaJTA:36765

Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	2011-03-01 14:30:41 UTC (rev 36765)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	2011-03-02 09:48:00 UTC (rev 36766)
@@ -198,15 +198,20 @@
      */
     public boolean updateIfEquivalentRM(XAResource xaResource, Xid[] xids)
     {
-        if(xids == null || xids.length == 0) {
-            return false;
+        if(xids != null && xids.length > 0) {
+            for(int i = 0; i < xids.length; i++) {
+                if(contains(xids[i])) {
+                    _xares = xaResource;
+                    return true;
+                }
+            }
         }
 
-        for(int i = 0; i < xids.length; i++) {
-            if(contains(xids[i])) {
-                _xares = xaResource;
-                return true;
-            }
+        // either (or both) passes have an empty Xid set,
+        // so fallback to isSameRM as we can't use Xid matching
+        if(isSameRM(xaResource)) {
+            _xares = xaResource;
+            return true;
         }
 
         return false;

Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	2011-03-01 14:30:41 UTC (rev 36765)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	2011-03-02 09:48:00 UTC (rev 36766)
@@ -247,12 +247,12 @@
 
         if (_xidScans != null)
 		{
-			Enumeration keys = _xidScans.keys();
+			Enumeration<XAResource> keys = _xidScans.keys();
 
 			while (keys.hasMoreElements())
 			{
-				XAResource theKey = (XAResource) keys.nextElement();
-				RecoveryXids xids = (RecoveryXids) _xidScans.get(theKey);
+				XAResource theKey = keys.nextElement();
+				RecoveryXids xids = _xidScans.get(theKey);
 
 				if (xids.contains(xid))
 					return theKey;
@@ -806,21 +806,24 @@
 			RecoveryXids xidsToRecover = null;
 
 			if (_xidScans == null)
-				_xidScans = new Hashtable();
+				_xidScans = new Hashtable<XAResource,RecoveryXids>();
 			else
 			{
                 refreshXidScansForEquivalentXAResourceImpl(xares, trans);
                 
-				xidsToRecover = (RecoveryXids) _xidScans.get(xares);
+				xidsToRecover = _xidScans.get(xares);
 
 				if (xidsToRecover == null)
 				{
-					java.util.Enumeration elements = _xidScans.elements();
+                    // this is probably redundant now due to updateIfEquivalentRM,
+                    // but in some implementations hashcode/equals does not behave itself.
+
+					java.util.Enumeration<RecoveryXids> elements = _xidScans.elements();
 					boolean found = false;
 
 					while (elements.hasMoreElements())
 					{
-						xidsToRecover = (RecoveryXids) elements.nextElement();
+						xidsToRecover = elements.nextElement();
 
 						if (xidsToRecover.isSameRM(xares))
 						{
@@ -1192,24 +1195,16 @@
      */
     private void refreshXidScansForEquivalentXAResourceImpl(XAResource xares, Xid[] xids)
     {
-        if(xids == null || xids.length == 0) {
-            return;
-        }
+        Set<XAResource> keys = new HashSet<XAResource>(_xidScans.keySet());
 
-        Enumeration keys = _xidScans.keys();
+        for(XAResource theKey : keys) {
+            RecoveryXids recoveryXids = _xidScans.get(theKey);
 
-        while (keys.hasMoreElements())
-        {
-            XAResource theKey = (XAResource) keys.nextElement();
-            RecoveryXids recoveryXids = (RecoveryXids) _xidScans.get(theKey);
-
             if(recoveryXids.updateIfEquivalentRM(xares, xids)) {
                 // recoveryXids is for this xares, but was originally obtained using
                 // a different XAResource. rekey the hashtable to use the new one.
                 _xidScans.remove(theKey);
-                theKey = xares;
-                _xidScans.put(theKey, recoveryXids);
-                break;
+                _xidScans.put(xares, recoveryXids);
             }
         }
     }
@@ -1378,7 +1373,7 @@
 
 	private Vector _xaRecoveryNodes = null;
 
-	private Hashtable _xidScans = null;
+	private Hashtable<XAResource,RecoveryXids> _xidScans = null;
 
 	private XARecoveryResourceManager _recoveryManagerClass = null;
 



More information about the jboss-svn-commits mailing list