Skip to content

Commit

Permalink
[INLONG-4212][Manager] The processor executor maybe throws a null poi…
Browse files Browse the repository at this point in the history
…nter exception (#4213)
  • Loading branch information
healchow authored May 16, 2022
1 parent c1e3bc3 commit b8bec82
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ public void executeStart(Element element, WorkflowContext context) {

// If it is a continuous task execution transaction isolation
if (element instanceof WorkflowTask) {
transactionHelper.execute(executeCompleteInTransaction(element, context),
TransactionDefinition.PROPAGATION_NESTED);
TransactionCallback<Object> callback = executeCompleteInTransaction(element, context);
if (callback != null) {
transactionHelper.execute(callback, TransactionDefinition.PROPAGATION_NESTED);
}
return;
}

Expand All @@ -120,7 +122,9 @@ public void executeComplete(Element element, WorkflowContext context) {
return;
}
List<Element> nextElements = processor.next(element, context);
nextElements.forEach(next -> executeStart(next, context));
for (Element next : nextElements) {
executeStart(next, context);
}
}

private boolean isSkipCurrentElement(Element element, WorkflowContext context) {
Expand Down Expand Up @@ -150,20 +154,20 @@ private void executeSkipAndNext(Element element, WorkflowContext context) {
// Execute next
context.getActionContext().setAction(((NextableElement) element).defaultNextAction());
List<Element> nextElements = processor.next(element, context);
nextElements.forEach(next -> executeStart(next, context));
for (Element next : nextElements) {
executeStart(next, context);
}
}

private TransactionCallback<Object> executeCompleteInTransaction(Element element, WorkflowContext context) {
return s -> {
try {
executeComplete(element, context);
return null;
} catch (WorkflowNoRollbackException e) { // Exception does not roll back
throw e;
} catch (Exception e) { // The exception is only rolled back once
throw new WorkflowRollbackOnceException(e.getMessage());
}
};
try {
executeComplete(element, context);
return null;
} catch (WorkflowNoRollbackException e) { // Exception does not roll back
throw e;
} catch (Exception e) { // The exception is only rolled back once
throw new WorkflowRollbackOnceException(e.getMessage());
}
}

}

0 comments on commit b8bec82

Please sign in to comment.