Index: jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	(revision 36765)
+++ jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	(revision 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;
Index: jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	(revision 36765)
+++ jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	(revision 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;
 

Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
   Merged /labs/jbosstm/trunk/ArjunaJTA:r36765

