Added null check to heatStack.getOutputs() 64/92264/2
authorOleksandr Moliavko <o.moliavko@samsung.com>
Tue, 30 Jul 2019 10:30:40 +0000 (13:30 +0300)
committerOleksandr Moliavko <o.moliavko@samsung.com>
Tue, 30 Jul 2019 12:35:34 +0000 (15:35 +0300)
to prevent crash at get() call; removed redundant
null check to simplify the code

Issue-ID: SO-1841
Signed-off-by: Oleksandr Moliavko <o.moliavko@samsung.com>
Change-Id: If9d8dcba3008cd7ebe60c17c08c71a07a6df9df4

adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java

index d9f47f5..c934291 100644 (file)
@@ -330,14 +330,15 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
                 } else {
                     // Populate the outputs from the existing stack.
                     networkId.value = heatStack.getCanonicalName();
-                    neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
-                    rollback.value = networkRollback; // Default rollback - no updates performed
-                    if (aic3template) {
-                        networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
-                    }
-                    Map<String, Object> outputs = heatStack.getOutputs();
                     Map<String, String> sMap = new HashMap<>();
-                    if (outputs != null) {
+                    if (heatStack.getOutputs() != null) {
+                        neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
+                        rollback.value = networkRollback; // Default rollback - no updates performed
+                        if (aic3template) {
+                            networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
+                        }
+                        Map<String, Object> outputs = heatStack.getOutputs();
+
                         for (Map.Entry<String, Object> entry : outputs.entrySet()) {
                             String key = entry.getKey();
                             if (key != null && key.startsWith("subnet")) {
@@ -437,9 +438,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             // For Heat-based orchestration, the MSO-tracked network ID is the heat stack,
             // and the neutronNetworkId is the network UUID returned in stack outputs.
             networkId.value = heatStack.getCanonicalName();
-            neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
-            if (aic3template) {
-                networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
+            if (heatStack.getOutputs() != null) {
+                neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
+                if (aic3template) {
+                    networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
+                }
             }
             Map<String, Object> outputs = heatStack.getOutputs();
             Map<String, String> sMap = new HashMap<>();