Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Ensure that input/output are correctly represented in transfer objects #2864

Merged
merged 7 commits into from
Mar 22, 2022
10 changes: 9 additions & 1 deletion core/src/main/java/com/netflix/conductor/model/TaskModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public long getQueueWaitTime() {
return 0L;
}

/** @return a deep copy of the task instance */
/** @return a copy of the task instance */
public TaskModel copy() {
TaskModel copy = new TaskModel();
BeanUtils.copyProperties(this, copy);
Expand Down Expand Up @@ -760,6 +760,14 @@ public Task toTask() {
Task task = new Task();
BeanUtils.copyProperties(this, task);
task.setStatus(Task.Status.valueOf(status.name()));

// ensure that input/output is properly represented
if (externalInputPayloadStoragePath != null) {
task.setInputData(new HashMap<>());
}
if (externalOutputPayloadStoragePath != null) {
task.setOutputData(new HashMap<>());
}
return task;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,6 @@ public void internalizeOutput(Map<String, Object> data) {
this.outputPayload = data;
}

/** @return a copy of the workflow instance */
public WorkflowModel copy() {
WorkflowModel copy = new WorkflowModel();
BeanUtils.copyProperties(this, copy);
return copy;
}

@Override
public String toString() {
String name = workflowDefinition != null ? workflowDefinition.getName() : null;
Expand Down Expand Up @@ -505,6 +498,14 @@ public Workflow toWorkflow() {
BeanUtils.copyProperties(this, workflow);
workflow.setStatus(Workflow.WorkflowStatus.valueOf(this.status.name()));
workflow.setTasks(tasks.stream().map(TaskModel::toTask).collect(Collectors.toList()));

// ensure that input/output is properly represented
if (externalInputPayloadStoragePath != null) {
workflow.setInput(new HashMap<>());
}
if (externalOutputPayloadStoragePath != null) {
workflow.setOutput(new HashMap<>());
}
return workflow;
}
}