aboutsummaryrefslogtreecommitdiffstats
path: root/container-disc/src/main/java/com/yahoo/container/usability/BindingsOverviewHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-disc/src/main/java/com/yahoo/container/usability/BindingsOverviewHandler.java')
-rw-r--r--container-disc/src/main/java/com/yahoo/container/usability/BindingsOverviewHandler.java11
1 files changed, 4 insertions, 7 deletions
diff --git a/container-disc/src/main/java/com/yahoo/container/usability/BindingsOverviewHandler.java b/container-disc/src/main/java/com/yahoo/container/usability/BindingsOverviewHandler.java
index c188f611b1d..c2e51590de4 100644
--- a/container-disc/src/main/java/com/yahoo/container/usability/BindingsOverviewHandler.java
+++ b/container-disc/src/main/java/com/yahoo/container/usability/BindingsOverviewHandler.java
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.usability;
+import ai.vespa.json.Jackson;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -32,7 +33,7 @@ import java.util.Map;
*/
public class BindingsOverviewHandler extends AbstractRequestHandler {
- private static final ObjectMapper jsonMapper = new ObjectMapper();
+ private static final ObjectMapper jsonMapper = Jackson.mapper();
private final JdiscBindingsConfig bindingsConfig;
@@ -54,21 +55,17 @@ public class BindingsOverviewHandler extends AbstractRequestHandler {
statusToReturn = com.yahoo.jdisc.Response.Status.OK;
}
- FastContentWriter writer = new FastContentWriter(new ResponseDispatch() {
+ try (FastContentWriter writer = new FastContentWriter(new ResponseDispatch() {
@Override
protected com.yahoo.jdisc.Response newResponse() {
com.yahoo.jdisc.Response response = new com.yahoo.jdisc.Response(statusToReturn);
response.headers().add("Content-Type", List.of("application/json"));
return response;
}
- }.connect(handler));
-
- try {
+ }.connect(handler))) {
writer.write(jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(json));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
- } finally {
- writer.close();
}
return new IgnoredContent();