Skip to content

Commit b680c29

Browse files
Use try-with-resources for EncodingTester
This change wraps the `new HtmlInputStreamReader` call in a try-with-resources construct, to ensure the HtmlInputStreamReader instance gets automatically closed. Without this change, Eclipse and other IDEs complain about the HtmlInputStreamReader instance never getting closed.
1 parent c526250 commit b680c29

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test-src/nu/validator/htmlparser/test/EncodingTester.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ private boolean runTest() throws IOException, SAXException {
6969
return false;
7070
}
7171
UntilHashInputStream stream = new UntilHashInputStream(aggregateStream);
72-
HtmlInputStreamReader reader = new HtmlInputStreamReader(stream, null,
73-
null, null, Heuristics.NONE, sniffingLimit);
72+
try (HtmlInputStreamReader reader = new HtmlInputStreamReader(stream, null,
73+
null, null, Heuristics.NONE, sniffingLimit)) {
7474
Charset charset = reader.getCharset();
7575
stream.close();
7676
if (skipLabel()) {
@@ -101,6 +101,7 @@ private boolean runTest() throws IOException, SAXException {
101101
System.err.println(stream);
102102
}
103103
return true;
104+
}
104105
}
105106

106107
private boolean skipLabel() throws IOException {

0 commit comments

Comments
 (0)