[jboss-svn-commits] JBL Code SVN: r35401 - in labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP: ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 4 06:55:39 EDT 2010


Author: jhalliday
Date: 2010-10-04 06:55:38 -0400 (Mon, 04 Oct 2010)
New Revision: 35401

Modified:
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java
Log:
Backport JTS cleanup sync / memory leak fix. JBTM-770


Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java	2010-10-04 07:52:01 UTC (rev 35400)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java	2010-10-04 10:55:38 UTC (rev 35401)
@@ -212,8 +212,11 @@
 	 * @message com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2
 	 *          [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2]
 	 *          TwoPhaseCoordinator.beforeCompletion - failed for {0}
-	 */
-
+     *
+     * Drive beforeCompletion participants.
+     *
+     * @return true if successful, false otherwise.
+     */
 	protected boolean beforeCompletion ()
 	{
 		boolean problem = false;
@@ -238,7 +241,7 @@
 					 * and we will rollback. Hence we don't then bother to call beforeCompletion
 					 * on the remaining records (it's not done for rollabcks anyhow).
 					 *
-					 * Since Synchronizations may add register other Synchronizations, we can't simply
+					 * Since Synchronizations may register other Synchronizations, we can't simply
 					 * iterate the collection. Instead we work from an ordered copy, which we periodically
 					 * check for freshness. The addSynchronization method uses _currentRecord to disallow
 					 * adding records in the part of the array we have already traversed, thus all
@@ -337,8 +340,13 @@
 	 * @message com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_4b
 	 *          [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_4b]
 	 *          TwoPhaseCoordinator.afterCompletion - failed for {0} with error {1}
-	 */
-
+     *
+     * Drive afterCompletion participants.
+     *
+     * @param myStatus the outcome of the transaction (ActionStatus.COMMITTED or ActionStatus.ABORTED).
+     *
+     * @return true if successful, false otherwise.
+     */
 	protected boolean afterCompletion (int myStatus)
 	{
 		if (myStatus == ActionStatus.RUNNING)

Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java	2010-10-04 07:52:01 UTC (rev 35400)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java	2010-10-04 10:55:38 UTC (rev 35401)
@@ -33,10 +33,6 @@
 
 import com.arjuna.ats.internal.jta.transaction.jts.TransactionImple;
 
-import com.arjuna.ats.jta.utils.JTAHelper;
-
-import javax.transaction.xa.*;
-
 /**
  * This synchronization is responsible for removing the JTA transaction
  * from the internal table. We don't need one for the purely local JTA

Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java	2010-10-04 07:52:01 UTC (rev 35400)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java	2010-10-04 10:55:38 UTC (rev 35401)
@@ -61,6 +61,7 @@
 
 import com.arjuna.ats.internal.jts.OTSImpleManager;
 import com.arjuna.ats.internal.jts.ControlWrapper;
+import com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple;
 
 import com.arjuna.common.util.logging.*;
 

Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java	2010-10-04 07:52:01 UTC (rev 35400)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java	2010-10-04 10:55:38 UTC (rev 35401)
@@ -1451,76 +1451,76 @@
 					+ get_uid());
 		}
 
-		boolean problem = false;
-		SystemException exp = null;
+	    boolean problem = false;
+	    SystemException exp = null;
 
-		/*
-		 * If we have a synchronization list then we must be top-level.
-		 */
-        if (_synchs != null)
-		{
-			boolean doSuspend = false;
-			ControlWrapper cw = null;
+	    /*
+	     * If we have a synchronization list then we must be top-level.
+	     */
+	    if (_synchs != null)
+	    {
+	        boolean doSuspend = false;
+	        ControlWrapper cw = null;
 
-			try
-			{
-				/*
-				 * Make sure that this transaction is active on the thread
-				 * before we invoke any Synchronizations. They are
-				 * TransactionalObjects and must have the context flowed to
-				 * them.
-				 */
+	        try
+	        {
+	            /*
+	             * Make sure that this transaction is active on the thread
+	             * before we invoke any Synchronizations. They are
+	             * TransactionalObjects and must have the context flowed to
+	             * them.
+	             */
 
-				try
-				{
-					//		    cw = OTSImpleManager.systemCurrent().getControlWrapper();
+	            try
+	            {
+	                //		    cw = OTSImpleManager.systemCurrent().getControlWrapper();
 
-					cw = OTSImpleManager.current().getControlWrapper();
+	                cw = OTSImpleManager.current().getControlWrapper();
 
-					/*
-					 * If there's no transaction incoming, then use the one that
-					 * we got at creation time.
-					 */
+	                /*
+	                 * If there's no transaction incoming, then use the one that
+	                 * we got at creation time.
+	                 */
 
-					if ((cw == null) || (!controlHandle.equals(cw.getImple())))
-					{
-						//			OTSImpleManager.systemCurrent().resumeImple(controlHandle);
+	                if ((cw == null) || (!controlHandle.equals(cw.getImple())))
+	                {
+	                    //			OTSImpleManager.systemCurrent().resumeImple(controlHandle);
 
-						OTSImpleManager.current().resumeImple(controlHandle);
+	                    OTSImpleManager.current().resumeImple(controlHandle);
 
-						doSuspend = true;
-					}
-				}
-				catch (Exception ex)
-				{
-					/*
-					 * It should be OK to continue with the invocations even if
-					 * we couldn't resume, because a Synchronization is only
-					 * supposed to be associated with a single transaction. So,
-					 * it should be able to infer the transaction.
-					 */
-				}
+	                    doSuspend = true;
+	                }
+	            }
+	            catch (Exception ex)
+	            {
+	                /*
+	                 * It should be OK to continue with the invocations even if
+	                 * we couldn't resume, because a Synchronization is only
+	                 * supposed to be associated with a single transaction. So,
+	                 * it should be able to infer the transaction.
+	                 */
+	            }
 
-               /*
-                * Since Synchronizations may add register other Synchronizations, we can't simply
-                * iterate the collection. Instead we work from an ordered copy, which we periodically
-                * check for freshness. The addSynchronization method uses _currentRecord to disallow
-                * adding records in the part of the array we have already traversed, thus all
-                * Synchronization will be called and the (jta only) rules on ordering of interposed
-                * Synchronization will be respected.
-                */
-               int lastIndexProcessed = -1;
-               SynchronizationRecord[] copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
+	            /*
+	             * Since Synchronizations may add register other Synchronizations, we can't simply
+	             * iterate the collection. Instead we work from an ordered copy, which we periodically
+	             * check for freshness. The addSynchronization method uses _currentRecord to disallow
+	             * adding records in the part of the array we have already traversed, thus all
+	             * Synchronization will be called and the (jta only) rules on ordering of interposed
+	             * Synchronization will be respected.
+	             */
+	            int lastIndexProcessed = -1;
+	            SynchronizationRecord[] copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
 
-               while( (lastIndexProcessed < _synchs.size()-1) && !problem) {
+	            while( (lastIndexProcessed < _synchs.size()-1) && !problem) {
 
-                   // if new Synchronization have been registered, refresh our copy of the collection:
-                   if(copiedSynchs.length != _synchs.size()) {
-                       copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
-                   }
+	                // if new Synchronization have been registered, refresh our copy of the collection:
+	                if(copiedSynchs.length != _synchs.size()) {
+	                    copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
+	                }
 
-                   lastIndexProcessed = lastIndexProcessed+1;
-                   _currentRecord = copiedSynchs[lastIndexProcessed];
+	                lastIndexProcessed = lastIndexProcessed+1;
+	                _currentRecord = copiedSynchs[lastIndexProcessed];
 
 					Synchronization c = _currentRecord.contents();
 					c.before_completion();
@@ -1534,27 +1534,27 @@
 					{ "ArjunaTransactionImple.doBeforeCompletion", e });
 				}
 
-				if (!problem)
-				{
-					exp = e;
+	            if (!problem)
+                {
+	                exp = e;
 
-					problem = true;
+	                problem = true;
 
-					/*
-					 * Mark as rollback_only, so when we try to commit it will
-					 * fail.
-					 */
+	                /*
+	                 * Mark as rollback_only, so when we try to commit it will
+	                 * fail.
+	                 */
 
-					try
-					{
-						rollback_only();
-					}
-					catch (Inactive ex)
-					{
-						/*
-						 * This should not happen. If it does, continue with
-						 * commit to tidy-up.
-						 */
+	                try
+                    {
+	                    rollback_only();
+	                }
+	                catch (Inactive ex)
+                    {
+	                    /*
+	                     * This should not happen. If it does, continue with
+	                     * commit to tidy-up.
+	                     */
 
 						if (jtsLogger.loggerI18N.isWarnEnabled())
 						{
@@ -1572,28 +1572,35 @@
 					{
 						//			OTSImpleManager.systemCurrent().resumeWrapper(cw);
 
-						if (cw != null)
-							OTSImpleManager.current().resumeWrapper(cw);
-						else
-							OTSImpleManager.current().suspend();
-					}
-					catch (Exception ex)
-					{
-					}
+	                    if (cw != null)
+	                        OTSImpleManager.current().resumeWrapper(cw);
+	                    else
+	                        OTSImpleManager.current().suspend();
+	                }
+	                catch (Exception ex)
+	                {
+	                }
 
-					//		    OTSImpleManager.systemCurrent().suspend();
-				}
-			}
-		}
+	                //		    OTSImpleManager.systemCurrent().suspend();
+	            }
+	        }
+	    }
+	    
+	    /*
+	     * If there's no problem so far then call beforeCompletion on the underlying TwoPhaseCoordinator.
+	     */
 
-		if (problem)
-		{
-			if (exp != null)
-				throw exp;
-			else
-				throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
-						CompletionStatus.COMPLETED_NO);
-		}
+        if (!problem)
+            problem = !super.beforeCompletion();
+	    
+	    if (problem)
+	    {
+	        if (exp != null)
+	            throw exp;
+	        else
+	            throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
+	                    CompletionStatus.COMPLETED_NO);
+	    }
 	}
 
 	/**
@@ -1621,67 +1628,67 @@
 			return;
 		}
 
-		boolean problem = false;
-		SystemException exp = null;
+	    boolean problem = false;
+	    SystemException exp = null;
 
-		if (_synchs != null)
-		{
-			ControlWrapper cw = null;
-			boolean doSuspend = false;
+	    if (_synchs != null)
+	    {
+	        ControlWrapper cw = null;
+	        boolean doSuspend = false;
 
-			try
-			{
-				//		cw = OTSImpleManager.systemCurrent().getControlWrapper();
+	        try
+	        {
+	            //		cw = OTSImpleManager.systemCurrent().getControlWrapper();
 
-				cw = OTSImpleManager.current().getControlWrapper();
+	            cw = OTSImpleManager.current().getControlWrapper();
 
-				/*
-				 * If there isn't a transaction context shipped, then use the
-				 * one we had during creation.
-				 */
+	            /*
+	             * If there isn't a transaction context shipped, then use the
+	             * one we had during creation.
+	             */
 
-				if ((cw == null) || (!controlHandle.equals(cw.getImple())))
-				{
-					//		    OTSImpleManager.systemCurrent().resumeImple(controlHandle);
+	            if ((cw == null) || (!controlHandle.equals(cw.getImple())))
+	            {
+	                //		    OTSImpleManager.systemCurrent().resumeImple(controlHandle);
 
-					OTSImpleManager.current().resumeImple(controlHandle);
+	                OTSImpleManager.current().resumeImple(controlHandle);
 
-					doSuspend = true;
-				}
-			}
-			catch (Exception ex)
-			{
-				/*
-				 * It should still be OK to make the call without a context
-				 * because a Synchronization can only be associated with a
-				 * single transaction.
-				 */
+	                doSuspend = true;
+	            }
+	        }
+	        catch (Exception ex)
+	        {
+	            /*
+	             * It should still be OK to make the call without a context
+	             * because a Synchronization can only be associated with a
+	             * single transaction.
+	             */
 
-				problem = true;
-			}
+	            problem = true;
+	        }
 
-			/*
-			 * Regardless of failures, we must tell all synchronizations what
-			 * happened.
-			 */
+	        /*
+	         * Regardless of failures, we must tell all synchronizations what
+	         * happened.
+	         */
 
-			// afterCompletions should run in reverse order compared to beforeCompletions
-			Stack stack = new Stack();
-			Iterator iterator = _synchs.iterator();
-			while(iterator.hasNext()) {
-				stack.push(iterator.next());
-			}
+	        // afterCompletions should run in reverse order compared to beforeCompletions
+	        Stack stack = new Stack();
+	        Iterator iterator = _synchs.iterator();
+	        while(iterator.hasNext()) {
+	            stack.push(iterator.next());
+	        }
 
-			iterator = stack.iterator();
+	        iterator = stack.iterator();
 
-			/*
-			 * Regardless of failures, we must tell all synchronizations what
-			 * happened.
-			 */
-			while(!stack.isEmpty())
-			{
-				SynchronizationRecord value = (SynchronizationRecord)stack.pop();
-				Synchronization c = value.contents();
+	        /*
+	         * Regardless of failures, we must tell all synchronizations what
+	         * happened.
+	         */
+	        while(!stack.isEmpty())
+	        {
+	            SynchronizationRecord value = (SynchronizationRecord)stack.pop();
+	            Synchronization c = value.contents();
 
 				try
 				{
@@ -1695,46 +1702,52 @@
 								+ e);
 					}
 
-					problem = true;
+	                problem = true;
 
-					/*
-					 * Remember the first exception we get, because it may well
-					 * be the only one. In which case we can return it, rather
-					 * than UNKNOWN.
-					 */
+	                /*
+	                 * Remember the first exception we get, because it may well
+	                 * be the only one. In which case we can return it, rather
+	                 * than UNKNOWN.
+	                 */
 
-					if (exp == null)
-						exp = e;
-				}
-			}
+	                if (exp == null)
+	                    exp = e;
+	            }
+	        }
 
-			if (doSuspend)
-			{
-				try
-				{
-					//		    OTSImpleManager.systemCurrent().resumeWrapper(cw);
+	        if (doSuspend)
+	        {
+	            try
+	            {
+	                //		    OTSImpleManager.systemCurrent().resumeWrapper(cw);
 
-					if (cw != null)
-						OTSImpleManager.current().resumeWrapper(cw);
-					else
-						OTSImpleManager.current().suspend();
-				}
-				catch (Exception ex)
-				{
-				}
-			}
+	                if (cw != null)
+	                    OTSImpleManager.current().resumeWrapper(cw);
+	                else
+	                    OTSImpleManager.current().suspend();
+	            }
+	            catch (Exception ex)
+	            {
+	            }
+	        }
 
-			_synchs = null;
-		}
+	        _synchs = null;
+	    }
 
-		if (problem)
-		{
-			if (exp != null)
-				throw exp;
-			else
-				throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
-						CompletionStatus.COMPLETED_NO);
-		}
+        /*
+        * If there's no problem so far then call afterCompletion on the underlying TwoPhaseCoordinator.
+        */
+
+        problem = !super.afterCompletion(myStatus == Status.StatusCommitted ? ActionStatus.COMMITTED : ActionStatus.ABORTED);
+
+        if (problem)
+	    {
+	        if (exp != null)
+	            throw exp;
+	        else
+	            throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
+	                    CompletionStatus.COMPLETED_NO);
+	    }
 	}
 
 	/**



More information about the jboss-svn-commits mailing list