Rewritten checks for status according to comments 78/93878/3
authorOleksandr Moliavko <o.moliavko@samsung.com>
Mon, 19 Aug 2019 14:56:28 +0000 (17:56 +0300)
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Wed, 21 Aug 2019 08:37:24 +0000 (08:37 +0000)
Issue-ID: SO-1841
Signed-off-by: Oleksandr Moliavko <o.moliavko@samsung.com>
Change-Id: I6023a043e2cf532de330060973d23a402a742e36

adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java

index e821d80..2a17656 100644 (file)
@@ -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);