Use AutoClosables with try-with-resources

Closes gh-33538
This commit is contained in:
Moritz Halbritter
2022-12-16 15:43:15 +01:00
parent 725337f976
commit f36e2ecb7b
16 changed files with 121 additions and 77 deletions

View File

@@ -294,9 +294,10 @@ class JarFileTests {
void getEntryUrlStream() throws Exception {
URL url = new URL(this.jarFile.getUrl(), "1.dat");
url.openConnection();
InputStream stream = url.openStream();
assertThat(stream.read()).isEqualTo(1);
assertThat(stream.read()).isEqualTo(-1);
try (InputStream stream = url.openStream()) {
assertThat(stream.read()).isEqualTo(1);
assertThat(stream.read()).isEqualTo(-1);
}
}
@Test