From 6960e9b70250fa1a09cfad5ad4bf68d434a76225 Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Tue, 13 Oct 2020 11:22:39 -0700 Subject: [PATCH] Fix NPE for failover query --- tools/cli/adminFailoverCommands.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/cli/adminFailoverCommands.go b/tools/cli/adminFailoverCommands.go index fc55bde8ae0..9ab1f6064a1 100644 --- a/tools/cli/adminFailoverCommands.go +++ b/tools/cli/adminFailoverCommands.go @@ -172,12 +172,17 @@ func AdminFailoverQuery(c *cli.Context) { if err != nil { ErrorAndExit("Failed to describe workflow", err) } - if descResp.WorkflowExecutionInfo.CloseStatus.Equals(shared.WorkflowExecutionCloseStatusTerminated) { + if isWorkflowTerminated(descResp) { result.State = failovermanager.WorkflowAborted } prettyPrintJSONObject(result) } +func isWorkflowTerminated(descResp *shared.DescribeWorkflowExecutionResponse) bool { + return descResp.WorkflowExecutionInfo.CloseStatus != nil && + descResp.WorkflowExecutionInfo.CloseStatus.Equals(shared.WorkflowExecutionCloseStatusTerminated) +} + // AdminFailoverAbort abort a failover workflow func AdminFailoverAbort(c *cli.Context) { client := getCadenceClient(c)