Skip to content

Commit

Permalink
Add warning when RPC response fails
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Pinto <[email protected]>
  • Loading branch information
lu-pinto committed Jan 18, 2025
1 parent 5235c5e commit 72788c3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JsonRpcObjectExecutor extends AbstractJsonRpcExecutor {
private static final Logger LOG = LoggerFactory.getLogger(AbstractJsonRpcExecutor.class);
private final ObjectWriter jsonObjectWriter = createObjectWriter();

public JsonRpcObjectExecutor(
Expand Down Expand Up @@ -76,7 +79,11 @@ private void handleJsonObjectResponse(
try (final JsonResponseStreamer streamer =
new JsonResponseStreamer(response, ctx.request().remoteAddress())) {
// underlying output stream lifecycle is managed by the json object writer
lazyTraceLogger(() -> getJsonObjectMapper().writeValueAsString(jsonRpcResponse));
if (jsonRpcResponse.getType() != RpcResponseType.ERROR) {
lazyTraceLogger(() -> getJsonObjectMapper().writeValueAsString(jsonRpcResponse));
} else {
LOG.warn("RPC error: {}", getJsonObjectMapper().writeValueAsString(jsonRpcResponse));
}
jsonObjectWriter.writeValue(streamer, jsonRpcResponse);
}
}
Expand Down

0 comments on commit 72788c3

Please sign in to comment.