Skip to content

Commit

Permalink
chore: Close input stream after using it (#12235)
Browse files Browse the repository at this point in the history
Fixes #9363
  • Loading branch information
Artur- authored Nov 2, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 35b942d commit 914ec13
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.stream.Collectors;
@@ -93,10 +94,9 @@ private static String getErrorHtml(boolean productionMode) {
}

private static String readHtmlFile(String templateName) {
try {
return IOUtils.toString(
RouteNotFoundError.class.getResourceAsStream(templateName),
StandardCharsets.UTF_8);
try (InputStream stream = RouteNotFoundError.class
.getResourceAsStream(templateName)) {
return IOUtils.toString(stream, StandardCharsets.UTF_8);
} catch (IOException e) {
getLogger().error("Unable to read " + templateName, e);
// Use a very simple error page if the real one could not be found

0 comments on commit 914ec13

Please sign in to comment.