From 79ec04301a726e8c48f1275877cb852d2d74adc0 Mon Sep 17 00:00:00 2001 From: Chris André Date: Fri, 24 Apr 2020 19:51:01 -0400 Subject: Work around potential NullPointerExceptions in HeatTreeManagerUtil - Replace null return values with empty Map objects Issue-ID: SDC-2928 Signed-off-by: Chris Andre Change-Id: I3357a8789a00201a7ffda1dbf0be5f08cbb9c33b --- .../openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java index 792d9a4854..9970a4d74c 100644 --- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java +++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java @@ -18,6 +18,7 @@ package org.openecomp.sdc.heat.services.tree; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Objects; @@ -142,7 +143,7 @@ public class HeatTreeManagerUtil { @SuppressWarnings("unchecked") public static Resource getResourceDef(Resource resource) { Resource resourceDef = null; - Map resourceDefValueMap = resource.getProperties() == null ? null + Map resourceDefValueMap = resource.getProperties() == null ? new HashMap<>() : (Map) resource.getProperties().get( PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap()); if (MapUtils.isNotEmpty(resourceDefValueMap)) { @@ -162,7 +163,7 @@ public class HeatTreeManagerUtil { public static void checkResourceGroupTypeValid(String filename, String resourceName, Resource resource, GlobalValidationContext globalContext) { - Map resourceDefValueMap = resource.getProperties() == null ? null + Map resourceDefValueMap = resource.getProperties() == null ? new HashMap<>() : (Map) resource.getProperties().get( PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap()); if (MapUtils.isNotEmpty(resourceDefValueMap)) { @@ -181,7 +182,7 @@ public class HeatTreeManagerUtil { public static void checkResourceTypeValid(String filename, String resourceName, Resource resource, GlobalValidationContext globalContext) { - Map resourceDefValueMap = resource.getProperties() == null ? null + Map resourceDefValueMap = resource.getProperties() == null ? new HashMap<>() : (Map) resource.getProperties().get(PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap()); if (MapUtils.isNotEmpty(resourceDefValueMap)) { Object resourceDefType = resourceDefValueMap.get(TYPE); @@ -202,7 +203,7 @@ public class HeatTreeManagerUtil { Resource resource, GlobalValidationContext globalContext) { //noinspection unchecked - Map resourceDefValueMap = resource.getProperties() == null ? null + Map resourceDefValueMap = resource.getProperties() == null ? new HashMap<>() : (Map) resource.getProperties().get(PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap()); if (MapUtils.isNotEmpty(resourceDefValueMap)) { Object resourceDefType = resourceDefValueMap.get(TYPE); -- cgit 1.2.3-korg