From 1980b0e778ae30a15ee1fdf4685097e6a8bc1d0d Mon Sep 17 00:00:00 2001 From: Oleksandr Moliavko Date: Mon, 19 Aug 2019 17:56:28 +0300 Subject: Rewritten checks for status according to comments Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko Change-Id: I6023a043e2cf532de330060973d23a402a742e36 --- .../java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index e821d806dd..2a17656f1d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -478,12 +478,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { boolean timedOut = false; int cancelTimeout = timeout; // TODO: For now, just use same timeout - String status = cancelExecution.getStatus(); - + String status = null; + if (cancelExecution != null) { + status = cancelExecution.getStatus(); + } // Poll for completion. Create a reusable cloudify query request GetExecution queryExecution = cloudify.executions().byId(executionId); - while (!timedOut && !status.equals(CANCELLED)) { + while (!timedOut && !CANCELLED.equals(status)) { // workflow is still running; check for timeout if (cancelTimeout <= 0) { logger.debug("Cancel timeout for workflow {} on deployment {}", workflowId, deploymentId); @@ -497,11 +499,13 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { logger.debug("pollTimeout remaining: {}", cancelTimeout); execution = queryExecution.execute(); - status = execution.getStatus(); + if (execution != null) { + status = execution.getStatus(); + } } // Broke the loop. Check again for a terminal state - if (status.equals(CANCELLED)) { + if (CANCELLED.equals(status)) { // Finished cancelling. Return the original exception logger.debug("Cancel workflow {} completed on deployment {}", workflowId, deploymentId); throw new MsoCloudifyException(-1, "", "", savedException); -- cgit 1.2.3-korg