From 7c61f08d9fd61437a762fe57277b6f1f780a14cb Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Thu, 24 Sep 2020 12:26:38 +0200 Subject: fix npe in ControllerExecutionBB Issue-ID: SO-3266 Signed-off-by: Lukasz Muszkieta Change-Id: Ib055c96bfd810fdf50e67d0c40fa6696850775a7 --- .../onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/onap') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java index 68161a8dd5..54922d4ea0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupPnf.java @@ -34,6 +34,8 @@ final class BBInputSetupPnf { } static void populatePnfToServiceInstance(Pnfs pnfs, String pnfId, ServiceInstance serviceInstance) { + removePnfFromServiceIfExists(serviceInstance, pnfId); + Pnf pnf = new Pnf(); pnf.setPnfId(pnfId); pnf.setPnfName(pnfs.getInstanceName()); @@ -45,4 +47,9 @@ final class BBInputSetupPnf { serviceInstance.getPnfs().add(pnf); } + + private static void removePnfFromServiceIfExists(ServiceInstance serviceInstance, String pnfId) { + serviceInstance.getPnfs().stream().filter(pnf -> pnf.getPnfId().equals(pnfId)).findFirst() + .ifPresent(serviceInstance.getPnfs()::remove); + } } -- cgit 1.2.3-korg