Skip to content

Commit

Permalink
Report the non-iterative scripting result status
Browse files Browse the repository at this point in the history
When re-working tasks in 4.4, we discarded the code that reported on
the operation result status of the non-iterative scripting action;
instead, we always reported "success".

This is now fixed. It should resolve MID-8056.
  • Loading branch information
mederly committed Nov 29, 2022
1 parent 5a5c857 commit 9bc0a57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
public class ScriptExecutionResult {

private String consoleOutput;
private List<PipelineItem> dataOutput; // unmodifiable + always non-null
private final String consoleOutput;
private final List<PipelineItem> dataOutput; // unmodifiable + always non-null

public ScriptExecutionResult(String consoleOutput, List<PipelineItem> dataOutput) {
this.consoleOutput = consoleOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class NonIterativeScriptingActivityHandler
private static final String LEGACY_HANDLER_URI = ModelPublicConstants.SCRIPT_EXECUTION_TASK_HANDLER_URI;
private static final Trace LOGGER = TraceManager.getTrace(NonIterativeScriptingActivityHandler.class);

private static final String OP_EXECUTE = NonIterativeScriptingActivityHandler.class.getName() + ".execute";

@PostConstruct
public void register() {
handlerRegistry.register(NonIterativeScriptingWorkDefinitionType.COMPLEX_TYPE, LEGACY_HANDLER_URI,
Expand Down Expand Up @@ -100,21 +102,32 @@ final static class MyActivityRun
}

@Override
protected @NotNull ActivityRunResult runLocally(OperationResult result)
throws CommonException {
protected @NotNull ActivityRunResult runLocally(OperationResult parentResult) throws CommonException {
RunningTask runningTask = getRunningTask();
ExecuteScriptType executeScriptRequest = getWorkDefinition().getScriptExecutionRequest().clone();
runningTask.setExecutionSupport(this);

// We need to create a subresult in order to be able to determine its status - we have to close it to get the status.
OperationResult result = parentResult.createSubresult(OP_EXECUTE);
try {
ScriptExecutionResult executionResult = getActivityHandler().scriptingService
.evaluateExpression(executeScriptRequest,
VariablesMap.emptyMap(), true, runningTask, result);
ScriptExecutionResult executionResult =
getActivityHandler().scriptingService
.evaluateExpression(
executeScriptRequest,
VariablesMap.emptyMap(),
true,
runningTask,
result);
LOGGER.debug("Execution output: {} item(s)", executionResult.getDataOutput().size());
LOGGER.debug("Execution result:\n{}", executionResult.getConsoleOutput());
return standardRunResult();
} catch (Throwable t) {
result.recordException(t);
throw t;
} finally {
runningTask.setExecutionSupport(null);
result.close();
}
return standardRunResult(result.getStatus());
}
}

Expand Down

0 comments on commit 9bc0a57

Please sign in to comment.