aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-04-09 13:09:37 +0200
committersebdet <sebastien.determe@intl.att.com>2019-04-09 13:09:37 +0200
commitfb35c3e3c80bd17308abfd34964e854ad9975342 (patch)
tree203b6fa14a4007a429c8271dcbe2b43a5fe77d26 /src/main
parentea77586a744fe9f69293e27d9e3553497f46c2a2 (diff)
Fix guard payload
Fix guard payload nullpointerException when guard list is empty or null Issue-ID: CLAMP-303 Change-Id: I6f714a877036cbc531dd35505202dde227cc224a Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index 1859a4d6e..1e35ad6c4 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -183,18 +183,20 @@ public class OperationalPolicy implements Serializable, Policy {
/**
* Return a map containing all Guard policies indexed by Guard policy Name.
- *
+ *
* @return The Guards map
*/
public Map<String, String> createGuardPolicyPayloads() {
Map<String, String> result = new HashMap<>();
- JsonObject guard = new JsonObject();
JsonElement guardsList = this.getConfigurationsJson().get("guard_policies");
- for (Entry<String, JsonElement> guardElem : guardsList.getAsJsonObject().entrySet()) {
- guard.addProperty("policy-id", guardElem.getKey());
- guard.add("contents", guardElem.getValue());
- result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard));
+ if (guardsList != null) {
+ for (Entry<String, JsonElement> guardElem : guardsList.getAsJsonObject().entrySet()) {
+ JsonObject guard = new JsonObject();
+ guard.addProperty("policy-id", guardElem.getKey());
+ guard.add("contents", guardElem.getValue());
+ result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard));
+ }
}
return result;
}