summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-11-17 08:37:28 -0500
committerDan Timoney <dtimoney@att.com>2020-11-17 08:37:28 -0500
commit652e1bb38db85b2646229a43935a47f42032a839 (patch)
tree4d24ec4106810e7522cf11eae773400b0bad397b
parent59135590f84f59007d0210131c609e8257a75150 (diff)
Fix NPE in toJsonString()
Fixed SvcLogicContext.toJsonString() to return the empty string () if it cannot find the requested prefix in the service logic context. Change-Id: I5e36864f961b36b6c82a3db8d20483df6686ed15 Issue-ID: CCSDK-2990 Signed-off-by: Dan Timoney <dtimoney@att.com>
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java
index 129c0852..98cf7e05 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java
@@ -298,7 +298,11 @@ public class SvcLogicContext {
String jsonString = this.toJsonString();
JsonObject jsonRoot = (JsonObject) jp.parse(jsonString);
JsonObject targetJson = jsonRoot.getAsJsonObject(pfx);
- return(targetJson.toString());
+ if (targetJson == null) {
+ return("");
+ } else {
+ return(targetJson.toString());
+ }
}
public String toJsonString() {