From 34e37ef828b082e3c4df403c3f6c32dd15521482 Mon Sep 17 00:00:00 2001 From: James DeMichele Date: Mon, 1 May 2023 22:17:36 -0500 Subject: [PATCH 1/2] Fix NPE for verify and repair if workflow not found --- .../conductor/core/reconciliation/WorkflowRepairService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java b/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java index f24aa9b1f6..8037a8b40f 100644 --- a/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java +++ b/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java @@ -12,9 +12,11 @@ */ package com.netflix.conductor.core.reconciliation; +import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Predicate; +import com.netflix.conductor.core.exception.NotFoundException; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,7 +103,8 @@ public boolean verifyAndRepairWorkflow(String workflowId, boolean includeTasks) /** Verify and repair tasks in a workflow. */ public void verifyAndRepairWorkflowTasks(String workflowId) { - WorkflowModel workflow = executionDAO.getWorkflow(workflowId, true); + WorkflowModel workflow = Optional.ofNullable(executionDAO.getWorkflow(workflowId, true)) + .orElseThrow(() -> new NotFoundException("Could not find workflow: " + workflowId)); workflow.getTasks().forEach(this::verifyAndRepairTask); // repair the parent workflow if needed verifyAndRepairWorkflow(workflow.getParentWorkflowId()); From e131870e55eff1b7add0e6afaa8a6af132433823 Mon Sep 17 00:00:00 2001 From: James DeMichele Date: Mon, 1 May 2023 22:18:57 -0500 Subject: [PATCH 2/2] spotless --- .../core/reconciliation/WorkflowRepairService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java b/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java index 8037a8b40f..ad47595232 100644 --- a/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java +++ b/core/src/main/java/com/netflix/conductor/core/reconciliation/WorkflowRepairService.java @@ -16,7 +16,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Predicate; -import com.netflix.conductor.core.exception.NotFoundException; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,6 +25,7 @@ import com.netflix.conductor.annotations.VisibleForTesting; import com.netflix.conductor.common.metadata.tasks.TaskType; import com.netflix.conductor.core.config.ConductorProperties; +import com.netflix.conductor.core.exception.NotFoundException; import com.netflix.conductor.core.execution.tasks.SystemTaskRegistry; import com.netflix.conductor.core.execution.tasks.WorkflowSystemTask; import com.netflix.conductor.core.utils.QueueUtils; @@ -103,8 +103,12 @@ public boolean verifyAndRepairWorkflow(String workflowId, boolean includeTasks) /** Verify and repair tasks in a workflow. */ public void verifyAndRepairWorkflowTasks(String workflowId) { - WorkflowModel workflow = Optional.ofNullable(executionDAO.getWorkflow(workflowId, true)) - .orElseThrow(() -> new NotFoundException("Could not find workflow: " + workflowId)); + WorkflowModel workflow = + Optional.ofNullable(executionDAO.getWorkflow(workflowId, true)) + .orElseThrow( + () -> + new NotFoundException( + "Could not find workflow: " + workflowId)); workflow.getTasks().forEach(this::verifyAndRepairTask); // repair the parent workflow if needed verifyAndRepairWorkflow(workflow.getParentWorkflowId());