From 652e1bb38db85b2646229a43935a47f42032a839 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 17 Nov 2020 08:37:28 -0500 Subject: 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 --- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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() { -- cgit 1.2.3-korg