BTM
  1. BTM
  2. BTM-16

Transaction.commit() does not disassociate the tx from the thread

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Invoking commit() or rollback() on the jta Transaction object (i.e. BitronixTransaction)
      does not invoke BitronixTransactionManager.clearCurrentContext(), unlike invoking
      commit() or rollback() on the TM. This means that TM.getTransaction() returns non-null
      even after a commit or rollback.

        Activity

        Hide
        Ludovic Orban added a comment -

        Implemented in trunk

        Show
        Ludovic Orban added a comment - Implemented in trunk
        Hide
        Nikita Tovstoles added a comment -

        This does not appear to be fixed in 1.3.2. BitronixTransactionManager.commit() does not call clearCurrentContext():

            public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
                BitronixTransaction currentTx = getCurrentTransaction();
                if (log.isDebugEnabled()) log.debug("committing transaction " + currentTx);
                if (currentTx == null)
                    throw new IllegalStateException("no transaction started on this thread");
        
                currentTx.commit();
            }
        

        yet JTA spec section 3.2.2 clearly states that TM must dissociate tx from calling thread by the time commit() returns:

        The TransactionManager.commit method completes the transaction currently
        associated with the calling thread. After the commit method returns, the calling thread
        is not associated with a transaction.

        Show
        Nikita Tovstoles added a comment - This does not appear to be fixed in 1.3.2. BitronixTransactionManager.commit() does not call clearCurrentContext(): public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { BitronixTransaction currentTx = getCurrentTransaction(); if (log.isDebugEnabled()) log.debug("committing transaction " + currentTx); if (currentTx == null) throw new IllegalStateException("no transaction started on this thread"); currentTx.commit(); } yet JTA spec section 3.2.2 clearly states that TM must dissociate tx from calling thread by the time commit() returns: The TransactionManager.commit method completes the transaction currently associated with the calling thread. After the commit method returns, the calling thread is not associated with a transaction.
        Hide
        Ludovic Orban added a comment -

        What you say is nonsense. Did you actually read all the comments and test how BTM behaves ?

        This bug was about moving the TX disassociation code from BitronixTransactionManager to BitronixTransaction to have more flexibility while still sticking to the JTA standard.

        If you find that something isn't working as it should be welcome to discuss it in the mailing list.

        Show
        Ludovic Orban added a comment - What you say is nonsense. Did you actually read all the comments and test how BTM behaves ? This bug was about moving the TX disassociation code from BitronixTransactionManager to BitronixTransaction to have more flexibility while still sticking to the JTA standard. If you find that something isn't working as it should be welcome to discuss it in the mailing list.
        Hide
        Nikita Tovstoles added a comment -

        I just wrote a test and you are correct - context does get cleared. My apologies for the false alarm - though I would describe my above post as inaccurate - not nonsense. Would you kindly point me to "all the comments" - I'd like to understand whether BTM takes TX off the thread before or after firing Synchronization.afterCompletion(). Thanks

        Show
        Nikita Tovstoles added a comment - I just wrote a test and you are correct - context does get cleared. My apologies for the false alarm - though I would describe my above post as inaccurate - not nonsense. Would you kindly point me to "all the comments" - I'd like to understand whether BTM takes TX off the thread before or after firing Synchronization.afterCompletion(). Thanks
        Hide
        Ludovic Orban added a comment -

        Sorry for the wrong wording, 'inaccurate' sounds better than 'nonsense' indeed.

        I was referring to all the comments of this bug, especially the ones from Ronald which best describe this change.

        Show
        Ludovic Orban added a comment - Sorry for the wrong wording, 'inaccurate' sounds better than 'nonsense' indeed. I was referring to all the comments of this bug, especially the ones from Ronald which best describe this change.

          People

          • Assignee:
            Ludovic Orban
            Reporter:
            Ronald Tschalär
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: