From 36537623004924c009ad7389910f52b9a7c078ec Mon Sep 17 00:00:00 2001 From: Angel Soto Date: Mon, 4 Mar 2024 18:35:04 +0100 Subject: [PATCH] Updating objectMapper usage --- .../main/java/co/rsk/rpc/netty/JsonRpcCustomServer.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rskj-core/src/main/java/co/rsk/rpc/netty/JsonRpcCustomServer.java b/rskj-core/src/main/java/co/rsk/rpc/netty/JsonRpcCustomServer.java index 4161e4a1255..58559b9ea70 100644 --- a/rskj-core/src/main/java/co/rsk/rpc/netty/JsonRpcCustomServer.java +++ b/rskj-core/src/main/java/co/rsk/rpc/netty/JsonRpcCustomServer.java @@ -107,13 +107,12 @@ private Set extractMethodNames(Class remoteInterface) { } private JsonResponse buildError(Object id, int errorCode, String errorMessage) { - ObjectMapper mapper = new ObjectMapper(); - ObjectNode response = mapper.createObjectNode(); + ObjectNode response = objectMapper.createObjectNode(); response.put(JSONRPC, VERSION); if(id != null) { - response.set(ID, mapper.valueToTree(id)); + response.set(ID, objectMapper.valueToTree(id)); } - ObjectNode error = mapper.createObjectNode(); + ObjectNode error = objectMapper.createObjectNode(); error.put(ERROR_CODE, errorCode); error.put(ERROR_MESSAGE, errorMessage);