Skip to content

Commit

Permalink
[Fix #3475] Do not abort process instance
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Apr 30, 2024
1 parent e5bfa81 commit 83b56c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ protected final void createTimerNode(RuleFlowNodeContainerFactory<?, ?> factory,

Map<String, String> metadata = state.getMetadata();
if (metadata != null) {
String errorMessage = state.getMetadata().get("errorMessage");
String errorMessage = metadata.get("errorMessage");
if (errorMessage != null && !errorMessage.isBlank()) {
NodeFactory<?, ?> errorMessageNode =
factory.actionNode(parserContext.newId()).action(new AbortExpressionActionSupplier(workflow.getExpressionLang(), errorMessage, SWFConstants.DEFAULT_WORKFLOW_VAR));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import org.jbpm.process.instance.ProcessInstance;
import org.jbpm.workflow.instance.NodeInstance;
import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;

import com.fasterxml.jackson.databind.JsonNode;

public class AbortExpressionAction extends BaseExpressionAction {

Expand All @@ -31,9 +32,12 @@ public AbortExpressionAction(String lang, String expr, String inputVar) {

public void execute(KogitoProcessContext context) throws Exception {
if (expr.isValid()) {
String error = evaluate(context, String.class);
if (error != null) {
setError(context, error);
JsonNode error = evaluate(context, JsonNode.class);
if (!error.isNull() && error.isTextual()) {
String errorStr = error.asText();
if (!errorStr.isBlank()) {
setError(context, errorStr);
}
}
} else {
setError(context, expr.toString());
Expand All @@ -42,7 +46,6 @@ public void execute(KogitoProcessContext context) throws Exception {

private void setError(KogitoProcessContext context, String error) {
ProcessInstance pi = (ProcessInstance) context.getProcessInstance();
pi.setErrorState((NodeInstance) context.getNodeInstance(), new AbortExpressionException(error));
pi.setState(KogitoProcessInstance.STATE_ABORTED);
pi.setErrorState((NodeInstance) context.getNodeInstance(), new IllegalArgumentException(error));
}
}

This file was deleted.

0 comments on commit 83b56c0

Please sign in to comment.