Skip to content

Commit

Permalink
Prevent a resource leak in the display help handler
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Oct 23, 2018
1 parent 50f263c commit c1b3853
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ public void execute(HttpRequest req, HttpResponse resp) throws IOException {

final String json = jsonBuilder.toString();

final String htmlTemplate =
new BufferedReader(new InputStreamReader(in, UTF_8)).lines()
.collect(Collectors.joining("\n"));
final String htmlTemplate;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, UTF_8))) {
htmlTemplate = reader.lines().collect(Collectors.joining("\n"));
}
final String updatedTemplate =
htmlTemplate.replace(HELPER_SERVLET_TEMPLATE_CONFIG_JSON_VAR, json);
if (resource.equals("/")) {
Expand Down

0 comments on commit c1b3853

Please sign in to comment.