From: Rodrigo Lima Date: Mon, 15 Jun 2020 21:21:00 +0000 (-0400) Subject: Fix sonar issues in Aggregate X-Git-Tag: 1.7.0~18^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=017c95fc8016787d17d060b586c3f5bd52582a04;p=aai%2Faai-common.git Fix sonar issues in Aggregate - check obj.isPresent() in method processInput - return Optional.empty instead of null in method createPropertiesObject Issue-ID: AAI-2934 Signed-off-by: Rodrigo Lima Change-Id: Iebe0184ce39f244dd56e6861617cbf4e5dafb06c --- diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java index b7627267..9ce343f6 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java @@ -129,7 +129,7 @@ public class Aggregate extends MultiFormatMapper { json.addProperty(prop.key(), gson.toJson(prop.value())); } else { // throw exception? - return null; + return Optional.empty(); } } } else { @@ -214,7 +214,7 @@ public class Aggregate extends MultiFormatMapper { json.add(inner); } else { Optional obj = this.getJsonFromVertex((Vertex)l, properties); - json.add(obj.get()); + if(obj.isPresent()) json.add(obj.get()); } } return Optional.of(json);