Skip to content

Commit

Permalink
attempt to open all resources before sending response header
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Sep 13, 2023
1 parent b857ff4 commit baa3e37
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public void handle(HttpExchange exchange) throws IOException {
switch (mtd) {
case "GET":
try {
FlightRecorderMXBean bean =
ManagementFactory.getPlatformMXBean(FlightRecorderMXBean.class);
List<String> xmlTexts =
bean.getConfigurations().stream()
.map(ConfigurationInfo::getContents)
.collect(Collectors.toList());
exchange.sendResponseHeaders(HttpStatus.SC_OK, BODY_LENGTH_UNKNOWN);
try (OutputStream response = exchange.getResponseBody()) {
FlightRecorderMXBean bean =
ManagementFactory.getPlatformMXBean(FlightRecorderMXBean.class);
List<String> xmlTexts =
bean.getConfigurations().stream()
.map(ConfigurationInfo::getContents)
.collect(Collectors.toList());
mapper.writeValue(response, xmlTexts);
}
} catch (Exception e) {
Expand Down

0 comments on commit baa3e37

Please sign in to comment.