From 4ec24592f5dfb1449f35ab48d3100a428a4f5e9e Mon Sep 17 00:00:00 2001 From: Oleksandr Moliavko Date: Tue, 20 Aug 2019 11:32:52 +0300 Subject: Added null check for rootNode to prevent crash at for loop. Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko Change-Id: I5ec16f3d73982c89e2bf5b14758274f1d4dd7740 --- .../so/adapters/network/MsoNetworkAdapterImpl.java | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 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 153de2fb12..be4cc5a05d 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 @@ -1521,23 +1521,28 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { logger.debug("Subnet_Ipam Output JSON String:{} {}", obj.getClass(), jStr); JsonNode rootNode = mapper.readTree(jStr); - for (JsonNode sNode : rootNode.path("ipam_subnets")) { - logger.debug("Output Subnet Node {}", sNode.toString()); - String name = sNode.path("subnet_name").textValue(); - String uuid = sNode.path("subnet_uuid").textValue(); - String aaiId = name; // default - // try to find aaiId for name in input subnetList - if (subnets != null) { - for (Subnet subnet : subnets) { - if (subnet != null && !commonUtils.isNullOrEmpty(subnet.getSubnetName())) { - if (subnet.getSubnetName().equals(name)) { - aaiId = subnet.getSubnetId(); - break; + if (rootNode != null) { + for (JsonNode sNode : rootNode.path("ipam_subnets")) { + logger.debug("Output Subnet Node {}", sNode.toString()); + String name = sNode.path("subnet_name").textValue(); + String uuid = sNode.path("subnet_uuid").textValue(); + String aaiId = name; // default + // try to find aaiId for name in input subnetList + if (subnets != null) { + for (Subnet subnet : subnets) { + if (subnet != null && !commonUtils.isNullOrEmpty(subnet.getSubnetName())) { + if (subnet.getSubnetName().equals(name)) { + aaiId = subnet.getSubnetId(); + break; + } } } } + sMap.put(aaiId, uuid); // bpmn needs aaid to uuid map } - sMap.put(aaiId, uuid); // bpmn needs aaid to uuid map + } else { + logger.error("{} {} null rootNode - cannot get subnet-uuids", MessageEnum.RA_MARSHING_ERROR, + ErrorCode.DataError.getValue()); } } catch (Exception e) { logger.error("{} {} Exception getting subnet-uuids ", MessageEnum.RA_MARSHING_ERROR, -- cgit 1.2.3-korg