From ff31b1eea7a5aec585fbbdf5004d2c1d93f4437e Mon Sep 17 00:00:00 2001 From: lding7 Date: Mon, 19 Mar 2018 16:22:01 +0800 Subject: fix sonar complaints NullPointerException in SDC bugs from https://sonar.onap.org/project/issues?id= org.openecomp.sdc%3Asdc-main%3A1.2.0-SNAPSHOT&open= AWIFjPUXRGy6eclHC_Q6&resolved=false&types=BUG and https://sonar.onap.org/project/issues?id= org.openecomp.sdc%3Asdc-main%3A1.2.0-SNAPSHOT&open= AWIFjPUXRGy6eclHC_Q5&resolved=false&types=BUG Change-Id: I88225e4da197bed62d588026564bd688a9627c8a Issue-ID: SDC-1146 Signed-off-by: lding7 --- .../impl/CompositionEntityDataManagerImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java index a00bd8e967..faa53862ef 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java @@ -212,16 +212,14 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa @Override public Set getAllErrorsByVsp(String vspId) { - CompositionEntityValidationData matchVsp = null; Set entitiesWithErrors = new HashSet<>(); for (CompositionEntityValidationData root : roots) { if (root.getEntityId().equals(vspId)) { - matchVsp = root; + getEntityListWithErrors(root, entitiesWithErrors); break; } } - getEntityListWithErrors(matchVsp, entitiesWithErrors); if (CollectionUtils.isNotEmpty(entitiesWithErrors)) { updateValidationCompositionEntityName(entitiesWithErrors); return entitiesWithErrors; @@ -449,6 +447,9 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa case vsp: CompositionEntityData vspEntity = getCompositionEntityDataById(entity); + if (Objects.isNull(vspEntity)) { + return null; + } VspQuestionnaireEntity vspQuestionnaireEntity = (VspQuestionnaireEntity) vspEntity.entity; VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(), -- cgit 1.2.3-korg