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 and vaadin-bot committed Nov 2, 2021
1 parent 97d6ad6 commit 1b852e3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,10 +87,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) {
LoggerFactory.getLogger(RouteNotFoundError.class)
.error("Unable to read " + templateName, e);
Expand Down

0 comments on commit 1b852e3

Please sign in to comment.