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<String> 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);