From bfc7997e306a59ce3c2640ea409fe0383d82588c Mon Sep 17 00:00:00 2001 From: Oleksandr Moliavko Date: Tue, 30 Jul 2019 13:30:40 +0300 Subject: Added null check to heatStack.getOutputs() to prevent crash at get() call; removed redundant null check to simplify the code Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko Change-Id: If9d8dcba3008cd7ebe60c17c08c71a07a6df9df4 --- .../so/adapters/network/MsoNetworkAdapterImpl.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/main/java') diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index d9f47f5c3a..c934291246 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -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 outputs = heatStack.getOutputs(); Map 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 outputs = heatStack.getOutputs(); + for (Map.Entry 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 outputs = heatStack.getOutputs(); Map sMap = new HashMap<>(); -- cgit 1.2.3-korg