Use try-with-resources instead of manual try/finally
This commit is contained in:
+2
-8
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user