Skip to content

Commit

Permalink
Update QueueableProcess.cls
Browse files Browse the repository at this point in the history
Fixes a subtle bug where the first or last elements in a queueable process couldn't hit the finalizer error handler because execute was called before the finalizer was attached.
  • Loading branch information
codefriar authored Dec 6, 2024
1 parent 863cc79 commit fd7df76
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public abstract class QueueableProcess implements Queueable, Database.AllowsCall
this.queueableContextHistory = new List<QueueableContext>();
}
this.queueableContextHistory.add(context);
// invoke the abstract method `execute`. see the comment above.
execute();

// create a new instance of the finalizer class. Note that we're passing in the list of remaining steps and the
// passthrough data.
Finalizer nextStep = new EnqueueNextQueueableProcessStep(
Expand All @@ -102,5 +101,7 @@ public abstract class QueueableProcess implements Queueable, Database.AllowsCall
// Attach the finalizer to system context. This will take care of enqueueing the next QueueableProcess step in
// the nextStep.
System.attachFinalizer(nextStep);
// invoke the abstract method `execute`. see the comment above.
execute();
}
}

0 comments on commit fd7df76

Please sign in to comment.