Fix NPE in toJsonString() 98/114998/1
authorDan Timoney <dtimoney@att.com>
Tue, 17 Nov 2020 13:37:28 +0000 (08:37 -0500)
committerDan Timoney <dtimoney@att.com>
Tue, 17 Nov 2020 13:37:28 +0000 (08:37 -0500)
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>
sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java

index 129c085..98cf7e0 100644 (file)
@@ -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() {