Skip to content

Commit

Permalink
fix(core): In nested flowable, return 0 instead of null output for it…
Browse files Browse the repository at this point in the history
…erationCount in waitFor task (#4700)

close #4657
  • Loading branch information
Skraye authored and loicmathieu committed Aug 22, 2024
1 parent 96b67b7 commit 0303e62
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/java/io/kestra/plugin/core/flow/WaitFor.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ private boolean reachedMaximums(RunContext runContext, Execution execution, Task
return false;
}

Integer iterationCount = (Integer) parentTaskRun.getOutputs().get("iterationCount");
Integer iterationCount = Optional.ofNullable(parentTaskRun.getOutputs())
.map(outputs -> (Integer) outputs.get("iterationCount"))
.orElse(0);
if (this.checkFrequency.maxIterations != null && iterationCount != null && iterationCount > this.checkFrequency.maxIterations) {
if (printLog) {logger.warn("Max iterations reached");}
return true;
Expand Down Expand Up @@ -236,7 +238,9 @@ public WaitFor.Output outputs(RunContext runContext) throws IllegalVariableEvalu

public WaitFor.Output outputs(TaskRun parentTaskRun) throws IllegalVariableEvaluationException {
String value = parentTaskRun != null ?
parentTaskRun.getOutputs().get("iterationCount").toString() : "0";
String.valueOf(Optional.ofNullable(parentTaskRun.getOutputs())
.map(outputs -> outputs.get("iterationCount"))
.orElse("0")) : "0";

return Output.builder()
.iterationCount(Integer.parseInt(value) + 1)
Expand Down

0 comments on commit 0303e62

Please sign in to comment.