From 566ae1c6de94d1bceb3f8b93db883cfa620560be Mon Sep 17 00:00:00 2001 From: franciscovila Date: Tue, 11 Jan 2022 12:29:08 +0000 Subject: Fix use of Optional in ComponentInstanceInputsMergeBL Issue-ID: SDC-3830 Signed-off-by: franciscovila Change-Id: I3504f3fdb449e2b236501eaa31dbe4e2cbda1247 --- .../merge/instance/ComponentInstanceInputsMergeBL.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java index d8b5020046..020c8a9aa1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java @@ -25,6 +25,7 @@ import fj.data.Either; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import org.openecomp.sdc.be.components.merge.VspComponentsMergeCommand; import org.openecomp.sdc.be.components.merge.property.DataDefinitionsValuesMergingBusinessLogic; @@ -111,10 +112,13 @@ public class ComponentInstanceInputsMergeBL implements VspComponentsMergeCommand private void mergeOldInstanceInputsValues(Component oldComponent, Component newComponent, String instanceId, List instInputs) { - ComponentInstance currentCompInstance = newComponent.getComponentInstanceById(instanceId).get(); - List oldInstInputs = - oldComponent == null ? Collections.emptyList() : oldComponent.safeGetComponentInstanceInputsByName(currentCompInstance.getName()); - List oldInputs = oldComponent == null ? Collections.emptyList() : oldComponent.getInputs(); - propertyValuesMergingBusinessLogic.mergeInstanceDataDefinitions(oldInstInputs, oldInputs, instInputs, newComponent.getInputs()); + Optional oCurrentCompInstance = newComponent.getComponentInstanceById(instanceId); + if (oCurrentCompInstance.isPresent()) { + ComponentInstance currentCompInstance = oCurrentCompInstance.get(); + List oldInstInputs = + oldComponent == null ? Collections.emptyList() : oldComponent.safeGetComponentInstanceInputsByName(currentCompInstance.getName()); + List oldInputs = oldComponent == null ? Collections.emptyList() : oldComponent.getInputs(); + propertyValuesMergingBusinessLogic.mergeInstanceDataDefinitions(oldInstInputs, oldInputs, instInputs, newComponent.getInputs()); + } } } -- cgit 1.2.3-korg