From 45a706e0d7d37cafadcf4e7a0afb17dc6b19695d Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Sun, 10 Jul 2016 15:43:29 -0400 Subject: [PATCH] Encode and then decode GET /metrics response to fix serialization issue with Vertx's JsonObject --- src/main/java/net/frozenorb/apiv3/route/GETMetrics.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/frozenorb/apiv3/route/GETMetrics.java b/src/main/java/net/frozenorb/apiv3/route/GETMetrics.java index 8bbbacf..9ee0821 100644 --- a/src/main/java/net/frozenorb/apiv3/route/GETMetrics.java +++ b/src/main/java/net/frozenorb/apiv3/route/GETMetrics.java @@ -5,6 +5,7 @@ import io.vertx.core.json.JsonObject; import io.vertx.ext.dropwizard.MetricsService; import io.vertx.ext.web.RoutingContext; import net.frozenorb.apiv3.APIv3; +import org.bson.Document; public final class GETMetrics implements Handler { @@ -12,7 +13,8 @@ public final class GETMetrics implements Handler { MetricsService metricsService = MetricsService.create(APIv3.getVertxInstance()); JsonObject metrics = metricsService.getMetricsSnapshot(APIv3.getVertxInstance()); - APIv3.respondJson(ctx, 200, metrics); + // We encode and then parse because JsonObject and Gson don't play nicely with each other + APIv3.respondJson(ctx, 200, Document.parse(metrics.encode())); } } \ No newline at end of file