summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-heat-lib/src/main/java/org
diff options
context:
space:
mode:
authorChris André <chris.andre@yoppworks.com>2020-04-24 19:51:01 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-04-27 15:37:04 +0000
commit79ec04301a726e8c48f1275877cb852d2d74adc0 (patch)
treec51d68df0fe358453a1bb794f67d4f506cbbbeeb /openecomp-be/lib/openecomp-heat-lib/src/main/java/org
parent4a4d45fadfbb61e8e147f2b62e5dab5ac55403e8 (diff)
Work around potential NullPointerExceptions in HeatTreeManagerUtil
- Replace null return values with empty Map objects Issue-ID: SDC-2928 Signed-off-by: Chris Andre <chris.andre@yoppworks.com> Change-Id: I3357a8789a00201a7ffda1dbf0be5f08cbb9c33b
Diffstat (limited to 'openecomp-be/lib/openecomp-heat-lib/src/main/java/org')
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java9
1 files 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<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? new HashMap<>()
: (Map<String, Object>) 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<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? new HashMap<>()
: (Map<String, Object>) 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<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? new HashMap<>()
: (Map<String, Object>) 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<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? new HashMap<>()
: (Map<String, Object>) resource.getProperties().get(PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
if (MapUtils.isNotEmpty(resourceDefValueMap)) {
Object resourceDefType = resourceDefValueMap.get(TYPE);