From d748b3efcde68fcff85164898bdd35d529b4127b Mon Sep 17 00:00:00 2001 From: romaingimbert Date: Mon, 23 Apr 2018 11:24:52 +0200 Subject: fix NPE on serviceInventory -service without VNF Change-Id: Ia61b6d63e2a35197074e7df70917d2aa6f53ee96 Issue-ID: EXTAPI-69 Signed-off-by: romaingimbert --- .../serviceinventory/ServiceInventoryService.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java index 707c9e9..a4347d4 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java @@ -102,16 +102,19 @@ public class ServiceInventoryService { List vnfs = new ArrayList<>(); LinkedHashMap relationShip = (LinkedHashMap) serviceResponse.get("relationship-list"); - List relationsList = (List) relationShip.get("relationship"); - for (LinkedHashMap relation : relationsList) { - String relatedLink = (String) relation.get("related-link"); - LinkedHashMap vnf = aaiClient.getVNF(relatedLink); - if (vnf != null) { - vnfs.add(vnf); + if(relationShip!=null) { + List relationsList = (List) relationShip.get("relationship"); + if(relationsList!=null) { + for (LinkedHashMap relation : relationsList) { + String relatedLink = (String) relation.get("related-link"); + LinkedHashMap vnf = aaiClient.getVNF(relatedLink); + if (vnf != null) { + vnfs.add(vnf); + } + } + serviceResponse.put("vnfs", vnfs); } } - serviceResponse.put("vnfs", vnfs); - } -- cgit 1.2.3-korg