From 2bdd4f82bb6d2d7928044228bf0893cf6aa5921d Mon Sep 17 00:00:00 2001 From: "priyanka.akhade" Date: Tue, 4 Aug 2020 19:07:52 +0530 Subject: Code improvement - Pending sonar issues Signed-off-by: priyanka.akhade Issue-ID: CLI-270 Change-Id: I11bff3e6fa5f3299ee3ad0f7bf5d3e42ee7a704c --- .../org/open/infc/grpc/server/OpenInterfaceGrpcServer.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'grpc/grpc-server') 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 c2a61320..ba9920cb 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 @@ -242,11 +242,7 @@ public class OpenInterfaceGrpcServer { // use the status from the plugin. reply.setSuccess(cmd.getResult().isPassed()); - try { - reply.putAttrs(OnapCommandConstants.RESULTS, new JsonParser().parse(printOut).toString()); - } catch (Exception e) { // NOSONAR - reply.putAttrs(OnapCommandConstants.RESULTS, printOut); - } + setOutputAttr(reply, printOut); output = reply.build(); logger.info("{}", output); @@ -279,6 +275,14 @@ public class OpenInterfaceGrpcServer { responseObserver.onCompleted(); } + public static void setOutputAttr(Builder reply, String printOut){ + try { + reply.putAttrs(OnapCommandConstants.RESULTS, new JsonParser().parse(printOut).toString()); + } catch (Exception e) { // NOSONAR + reply.putAttrs(OnapCommandConstants.RESULTS, printOut); + } + } + @Override public void remoteCli(Args req, StreamObserver responseObserver) { logger.info("{}", req); -- cgit 1.2.3-korg