From 83c91e61a7dd84394c8df763915ed09d97fcb407 Mon Sep 17 00:00:00 2001 From: Oleksandr Moliavko Date: Wed, 10 Jul 2019 14:04:26 +0300 Subject: Added null check for function param pFqdns to prevent crash at for loop. Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko Change-Id: I5e72e1c6d74c5f197479062348090ab2b87fafae --- .../so/adapters/network/MsoNetworkAdapterImpl.java | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/main/java/org/onap') 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 5dff4705af..d9f47f5c3a 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 @@ -1294,15 +1294,23 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Resource Property List prlist = new ArrayList<>(); int index = 1; - for (String pf : pFqdns) { - if (!commonUtils.isNullOrEmpty(pf)) { - ContrailPolicyRef pr = new ContrailPolicyRef(); - ContrailPolicyRefSeq refSeq = new ContrailPolicyRefSeq(String.valueOf(index), "0"); - pr.setSeq(refSeq); - index++; - logger.debug("Contrail PolicyRefs Data:{}", pr); - prlist.add(pr); + + if (pFqdns != null) { + for (String pf : pFqdns) { + if (!commonUtils.isNullOrEmpty(pf)) { + ContrailPolicyRef pr = new ContrailPolicyRef(); + ContrailPolicyRefSeq refSeq = new ContrailPolicyRefSeq(String.valueOf(index), "0"); + pr.setSeq(refSeq); + index++; + logger.debug("Contrail PolicyRefs Data:{}", pr); + prlist.add(pr); + } } + } else { + String error = "Null pFqdns at start of mergePolicyRefs"; + logger.error(LoggingAnchor.THREE, MessageEnum.RA_MARSHING_ERROR, ErrorCode.BusinessProcesssError.getValue(), + error); + throw new MsoAdapterException(error); } JsonNode node = null; -- cgit 1.2.3-korg