Use try-with-resources instead of manual try/finally

This commit is contained in:
Alexander Udalov
2017-04-01 00:06:30 +03:00
parent 08b50cab08
commit 463bbbd386
8 changed files with 29 additions and 60 deletions
@@ -170,10 +170,8 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
File outputFile = new File(jarPath.getParentFile(), FileUtil.getNameWithoutExtension(jarPath) + "-after.jar");
Set<String> toDelete = SetsKt.setOf(entriesToDelete);
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
JarFile jar = new JarFile(jarPath);
ZipOutputStream output = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
try {
try (JarFile jar = new JarFile(jarPath);
ZipOutputStream output = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)))) {
for (Enumeration<JarEntry> enumeration = jar.entries(); enumeration.hasMoreElements(); ) {
JarEntry jarEntry = enumeration.nextElement();
String name = jarEntry.getName();
@@ -189,10 +187,6 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
output.closeEntry();
}
}
finally {
output.close();
jar.close();
}
return outputFile;
}