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

Fix schedule work aftercommit without Transaction

    XMLWordPrintable

    Details

      Description

      When scheduling a work after commit outside a transaction, then the work is never run and stay in the queue indefinitely.

      This is reproducible with a unit unit test annotated with

      @TransactionalConfig(autoStart=false)
      

      The schedule method should throw an exception if afterCommit=true.

      Also the default behaviour is afterCommit=false which is a quite uncommon use case, I suggest:

      diff --git i/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkManagerImpl.java w/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkManagerImpl.java
      index 3758a8b..4ee68d2 100644
      --- i/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkManagerImpl.java
      +++ w/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkManagerImpl.java
      @@ -747,7 +747,7 @@ public class WorkManagerImpl extends DefaultComponent implements WorkManager {
       
           @Override
           public void schedule(Work work) {
      -        schedule(work, Scheduling.ENQUEUE, false);
      +        schedule(work, Scheduling.ENQUEUE, true);
           }
       
           @Override
      @@ -757,7 +757,7 @@ public class WorkManagerImpl extends DefaultComponent implements WorkManager {
       
           @Override
           public void schedule(Work work, Scheduling scheduling) {
      -        schedule(work, scheduling, false);
      +        schedule(work, scheduling, true);
           }
       
           @Override
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 2 hours
                2h
                Remaining:
                Remaining Estimate - 2 hours
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified