diff options
author | priyanka.akhade <priyanka.akhade@huawei.com> | 2020-02-28 05:47:34 +0000 |
---|---|---|
committer | priyanka.akhade <priyanka.akhade@huawei.com> | 2020-02-29 11:26:08 +0000 |
commit | 132177fb71c08f157fb42037f9dd26ceb2d0ba43 (patch) | |
tree | f47d3c4d950e98d5bcf104aa8952f39a84e3ba6d /grpc/grpc-server/src/main/java/org/open | |
parent | 4f1d279e42a3326cdc97e1eacaf0fdb58ee944e7 (diff) |
Migrate to gson
Issue-ID: CLI-247
Signed-off-by: priyanka.akhade <priyanka.akhade@huawei.com>
Change-Id: If66134db5503382fb45210ece883402fc130ac93
Diffstat (limited to 'grpc/grpc-server/src/main/java/org/open')
-rw-r--r-- | grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java b/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java index 9f325067..8b9448b7 100644 --- a/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java +++ b/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java @@ -45,7 +45,8 @@ import org.open.infc.grpc.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import io.grpc.Server; import io.grpc.ServerBuilder; @@ -54,6 +55,7 @@ import io.grpc.stub.StreamObserver; public class OpenInterfaceGrpcServer { private static final Logger logger = LoggerFactory.getLogger(OpenInterfaceGrpcServer.class.getName()); + private static Gson gson = new GsonBuilder().serializeNulls().create(); private static final String CONF_FILE = "oclip-grpc-server.properties"; private static final String CONF_SERVER_PORT = "oclip.grpc_server_port"; @@ -246,8 +248,8 @@ public class OpenInterfaceGrpcServer { reply.setSuccess(cmd.getResult().isPassed()); try { - reply.putAttrs(OnapCommandConstants.RESULTS, new ObjectMapper().readTree(printOut).toString()); - } catch (IOException e) { + reply.putAttrs(OnapCommandConstants.RESULTS, gson.fromJson(printOut,String.class)); + } catch (Exception e) { // NOSONAR reply.putAttrs(OnapCommandConstants.RESULTS, printOut); } |