aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/main
diff options
context:
space:
mode:
authorOleksandr Moliavko <o.moliavko@samsung.com>2019-08-21 09:55:13 +0300
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-08-21 15:48:00 +0000
commit6f111a4c24ecd42c874d349081efbbd8376ab715 (patch)
tree2873d83d5ceff284e471ead291079b78b58cc833 /adapters/mso-adapter-utils/src/main
parenta7221b99f36b572ba896160e7878b92fb65e8145 (diff)
Added null check for latestStack to prevent crash
at method calls; moved latestStack declaration according to comment by maintainer Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko <o.moliavko@samsung.com> Change-Id: Ic4bfeca94103f6c902808de39df752569580c066
Diffstat (limited to 'adapters/mso-adapter-utils/src/main')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index 6565db7ebc..b5a97f7559 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -327,20 +327,24 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
Integer.parseInt(this.environment.getProperty(pollingMultiplierProp, POLLING_MULTIPLIER_DEFAULT));
int numberOfPollingAttempts = Math.floorDiv((timeoutMinutes * pollingMultiplier), pollingFrequency);
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
- Stack latestStack = null;
while (true) {
- latestStack = queryHeatStack(heatClient, stack.getStackName() + "/" + stack.getId());
- statusHandler.updateStackStatus(latestStack);
- logger.debug("Polling: {} ({})", latestStack.getStackStatus(), latestStack.getStackName());
- if (stackStatus.equals(latestStack.getStackStatus())) {
- if (numberOfPollingAttempts <= 0) {
- logger.error("Polling of stack timed out with Status: {}", latestStack.getStackStatus());
+ Stack latestStack = queryHeatStack(heatClient, stack.getStackName() + "/" + stack.getId());
+ if (latestStack != null) {
+ statusHandler.updateStackStatus(latestStack);
+ logger.debug("Polling: {} ({})", latestStack.getStackStatus(), latestStack.getStackName());
+ if (stackStatus.equals(latestStack.getStackStatus())) {
+ if (numberOfPollingAttempts <= 0) {
+ logger.error("Polling of stack timed out with Status: {}", latestStack.getStackStatus());
+ return latestStack;
+ }
+ sleep(pollingFrequency * 1000L);
+ numberOfPollingAttempts -= 1;
+ } else {
return latestStack;
}
- sleep(pollingFrequency * 1000L);
- numberOfPollingAttempts -= 1;
} else {
- return latestStack;
+ logger.error("latestStack is null");
+ return null;
}
}
}