[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...

Manik Surtani manik at jboss.org
Mon Apr 2 19:34:21 EDT 2007


  User: msurtani
  Date: 07/04/02 19:34:21

  Modified:    src/org/jboss/cache/interceptors  TxInterceptor.java
  Log:
  JBCACHE-1007
  
  Revision  Changes    Path
  1.80      +57 -21    JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TxInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -b -r1.79 -r1.80
  --- TxInterceptor.java	28 Feb 2007 18:22:54 -0000	1.79
  +++ TxInterceptor.java	2 Apr 2007 23:34:21 -0000	1.80
  @@ -215,7 +215,10 @@
            }
   
   
  -         if (log.isTraceEnabled()) {log.trace("Resuming existing transaction " + ltx + ", global TX=" + gtx);}
  +         if (log.isTraceEnabled())
  +         {
  +            log.trace("Resuming existing transaction " + ltx + ", global TX=" + gtx);
  +         }
   
            // at this point we have a non-null ltx
   
  @@ -417,7 +420,10 @@
         finally
         {
   
  -         if (log.isTraceEnabled()) {log.trace("Are we running a 1-phase commit? " + commit);}
  +         if (log.isTraceEnabled())
  +         {
  +            log.trace("Are we running a 1-phase commit? " + commit);
  +         }
            // 4. If commit == true (one-phase-commit): commit (or rollback) the TX; this will cause
            //    {before/after}Completion() to be called in all registered interceptors: the TransactionInterceptor
            //    will then commit/rollback against the cache
  @@ -700,7 +706,10 @@
               commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, gtx);
            }
   
  -         if (log.isTraceEnabled()) {log.trace(" running commit for " + gtx);}
  +         if (log.isTraceEnabled())
  +         {
  +            log.trace(" running commit for " + gtx);
  +         }
            handleCommitRollback(commitMethod);
         }
         catch (Throwable e)
  @@ -751,7 +760,10 @@
            // JBCACHE-457
            //            MethodCall rollbackMethod = MethodCall(CacheImpl.rollbackMethod, new Object[]{gtx, hasMods ? true : false});
            MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, gtx);
  -         if (log.isTraceEnabled()) {log.trace(" running rollback for " + gtx);}
  +         if (log.isTraceEnabled())
  +         {
  +            log.trace(" running rollback for " + gtx);
  +         }
   
            //JBCACHE-359 Store a lookup for the gtx so a listener
            // callback can find it
  @@ -844,11 +856,17 @@
            if (gtx.isRemote())
            {
               // should be no need to register a handler since this a remotely initiated gtx
  -            if (log.isTraceEnabled()) {log.trace("is a remotely initiated gtx so no need to register a tx for it");}
  +            if (log.isTraceEnabled())
  +            {
  +               log.trace("is a remotely initiated gtx so no need to register a tx for it");
  +            }
            }
            else
            {
  -            if (log.isTraceEnabled()) {log.trace("Registering sync handler for tx " + tx + ", gtx " + gtx);}
  +            if (log.isTraceEnabled())
  +            {
  +               log.trace("Registering sync handler for tx " + tx + ", gtx " + gtx);
  +            }
               LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, cache);
               registerHandler(tx, myHandler);
            }
  @@ -912,7 +930,10 @@
       */
      private Transaction createLocalTx() throws Exception
      {
  -      if (log.isTraceEnabled()) {log.trace("Creating transaction for thread " + Thread.currentThread());}
  +      if (log.isTraceEnabled())
  +      {
  +         log.trace("Creating transaction for thread " + Thread.currentThread());
  +      }
         Transaction localTx;
         if (txManager == null) throw new Exception("Failed to create local transaction; TransactionManager is null");
         txManager.begin();
  @@ -943,7 +964,7 @@
   
      // this controls the whole transaction
   
  -   class RemoteSynchronizationHandler implements Synchronization
  +   private class RemoteSynchronizationHandler implements Synchronization
      {
         Transaction tx = null;
         GlobalTransaction gtx = null;
  @@ -1028,7 +1049,22 @@
               txTable.remove(gtx);
               txTable.remove(tx);
               setTransactionalContext(null, null);
  +            cleanupInternalState();
  +         }
            }
  +
  +      /**
  +       * Cleans out (nullifies) member variables held by the sync object for easier gc.  Could be (falsely) seen as a mem
  +       * leak if the TM implementation hangs on to the synchronizations for an unnecessarily long time even after the tx
  +       * completes.  See JBCACHE-1007.
  +       */
  +      private void cleanupInternalState()
  +      {
  +         this.tx = null;
  +         this.gtx = null;
  +         this.cache = null;
  +         this.modifications = null;
  +         this.entry = null;
         }
   
         public String toString()
  @@ -1037,7 +1073,7 @@
         }
      }
   
  -   class LocalSynchronizationHandler extends RemoteSynchronizationHandler
  +   private class LocalSynchronizationHandler extends RemoteSynchronizationHandler
      {
         private boolean localRollbackOnly = true;
   
  
  
  



More information about the jboss-cvs-commits mailing list