Moved null check for outputs so that get() method 58/93158/1
authorOleksandr Moliavko <o.moliavko@samsung.com>
Fri, 9 Aug 2019 07:47:43 +0000 (10:47 +0300)
committerOleksandr Moliavko <o.moliavko@samsung.com>
Fri, 9 Aug 2019 07:47:43 +0000 (10:47 +0300)
call won't result in crash.

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

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

index c934291..64f1b21 100644 (file)
@@ -914,7 +914,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
         // Use MsoNeutronUtils for all NEUTRON commands
 
         String mode;
-        String neutronId;
+        String neutronId = null;
         // Try Heat first, since networks may be named the same as the Heat stack
         StackInfo heatStack = null;
         long queryStackStarttime = System.currentTimeMillis();
@@ -930,12 +930,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
         // Populate the outputs based on the returned Stack information
         if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) {
             // Found it. Get the neutronNetworkId for further query
+            Map<String, String> sMap = new HashMap<>();
             Map<String, Object> outputs = heatStack.getOutputs();
-            neutronId = (String) outputs.get(NETWORK_ID);
             mode = "HEAT";
-
-            Map<String, String> sMap = new HashMap<>();
             if (outputs != null) {
+                neutronId = (String) outputs.get(NETWORK_ID);
+
                 for (String key : outputs.keySet()) {
                     if (key != null && key.startsWith("subnet_id_")) // multiples subnet_%aaid% outputs
                     {