aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Lima <rodrigo.lima@yoppworks.com>2020-04-21 15:17:29 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-04-22 11:00:14 +0000
commit8a5065a44e64cd9eabbb2c16d262eb88be3d0c43 (patch)
treeb47eb4bc27fb7b69448716f528480a7d562ac62a
parent80a4b4a14a63509990bdbcb960538d30ae22a6e5 (diff)
Handle null condition in ResourceImportManager
- check if parentResource null in methods setRequirements and setCapabilities Issue-ID: SDC-2912 Signed-off-by: Rodrigo Lima <rodrigo.lima@yoppworks.com> Change-Id: I1ea5a8cf26e3883b5d26fb970bc0abc4cbf1ee9a
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 6b0b6bf81c..79543ce5cf 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -461,11 +461,11 @@ public class ResourceImportManager {
Boolean validateVsParentCap = validateCapNameVsDerived(reqName2TypeMap, requirementDef
.getCapability(), requirementDef.getName());
if (!validateVsParentCap) {
- log.debug("Requirement with name {} already exists in parent {}", requirementDef.getName(), parentResource
- .getName());
+ String parentResourceName = parentResource != null ? parentResource.getName() : "";
+ log.debug("Requirement with name {} already exists in parent {}", requirementDef.getName(), parentResourceName);
throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "requirement", requirementDef
.getName()
- .toLowerCase(), parentResource.getName());
+ .toLowerCase(), parentResourceName);
}
}
if (moduleRequirements.size() > 0) {
@@ -623,11 +623,12 @@ public class ResourceImportManager {
if (!validateVsParentCap) {
// Here parentResource is for sure not null, so it's
// null-safe
- log.debug("Capability with name {} already exists in parent {}", capabilityDef.getName(), parentResource
- .getName());
+ // Check added to avoid sonar warning
+ String parentResourceName = parentResource != null ? parentResource.getName() : "";
+ log.debug("Capability with name {} already exists in parent {}", capabilityDef.getName(), parentResourceName);
throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "capability", capabilityDef
.getName()
- .toLowerCase(), parentResource.getName());
+ .toLowerCase(), parentResourceName);
}
}
if (moduleCapabilities.size() > 0) {