Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-19618

Fix PublisherServiceImpl startup not to start a transaction when one is already active

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 7.10-HF07
    • Fix Version/s: 7.10-HF10, 8.3
    • Component/s: Tests
    • Tags:
    • Backlog priority:
      500
    • Sprint:
      nxDM 8.3.3
    • Story Points:
      2

      Description

      The method PublisherServiceImpl#applicationStarted starts a transaction without testing if a transaction is already active as it is commonly done with the following pattern

              boolean started = TransactionHelper.isTransactionActive() == false && TransactionHelper.startTransaction();
              try {
                  // your code here
              } finally {
                  if (started) {
                      TransactionHelper.commitOrRollbackTransaction();
                  }
              }
      

      This could cause a NotSupportedException indicating that nested transactions are not supported with this stacktrace:

      ERROR [TransactionHelper] Unable to start transaction
      javax.transaction.NotSupportedException: Nested Transactions are not supported
      	at org.apache.geronimo.transaction.manager.TransactionManagerImpl.begin(TransactionManagerImpl.java:157)
      	at org.apache.geronimo.transaction.manager.TransactionManagerImpl.begin(TransactionManagerImpl.java:152)
      	at org.nuxeo.runtime.jtajca.NuxeoContainer$UserTransactionImpl.begin(NuxeoContainer.java:525)
      	at org.nuxeo.runtime.transaction.TransactionHelper.startTransaction(TransactionHelper.java:193)
      	at org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl.applicationStarted(PublisherServiceImpl.java:102)
      	at org.nuxeo.runtime.model.impl.RegistrationInfoImpl.notifyApplicationStarted(RegistrationInfoImpl.java:325)
      	at org.nuxeo.runtime.osgi.OSGiRuntimeService.notifyComponentsOnStarted(OSGiRuntimeService.java:482)
      	at org.nuxeo.runtime.osgi.OSGiRuntimeService.fireApplicationStarted(OSGiRuntimeService.java:518)
      	at org.nuxeo.runtime.api.ServicePassivator$Waiter.proceed(ServicePassivator.java:413)
      	at org.nuxeo.runtime.api.ServicePassivator.proceed(ServicePassivator.java:81)
      	at org.nuxeo.runtime.osgi.OSGiRuntimeService.frameworkEvent(OSGiRuntimeService.java:530)
      	at org.nuxeo.osgi.OSGiAdapter.fireFrameworkEvent(OSGiAdapter.java:232)
      	at org.nuxeo.runtime.test.NXRuntimeTestCase.fireFrameworkStarted(NXRuntimeTestCase.java:193)
      

      The error is reproducible in a unit test where NXRuntimeTestCase.fireFrameworkStarted has already started a transaction, since NXP-19049

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 30 minutes
                  1h 30m