Cleaning up file-handling code
Close file in test
@@ -78,8 +78,11 @@ public class FileUtilsTest {
}
File target = aTempDir.resolve("target").toFile();
+
+ try (JarFile jarFile = new JarFile(zipFile)) {
assertThatExceptionOfType(IOException.class)
- .isThrownBy(() -> extractFilesFromJar(new JarFile(zipFile), target))
+ .isThrownBy(() -> extractFilesFromJar(jarFile, target))
.withMessageContaining("Can only write within target folder");
}
}
+}
