From 35acb11f77a4649fc844676693e1b6a5adc7fab6 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 11 Mar 2021 13:16:46 +0700 Subject: [PATCH] AjBuildManager: use try with resources in 2 places I was debugging something in ModuleTests, trying to find out if there are resource leaks. They were not in this class but in FileUtil - see next commit. However, the little refactoring here does not hurt either. Signed-off-by: Alexander Kriegisch --- .../ajdt/internal/core/builder/AjBuildManager.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index fb086e9f3..87df28f0c 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -476,9 +476,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } private void copyResourcesFromJarFile(File jarFile) throws IOException { - JarInputStream inStream = null; - try { - inStream = new JarInputStream(new FileInputStream(jarFile)); + try (JarInputStream inStream = new JarInputStream(new FileInputStream(jarFile))) { while (true) { ZipEntry entry = inStream.getNextEntry(); if (entry == null) { @@ -496,10 +494,6 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour inStream.closeEntry(); } - } finally { - if (inStream != null) { - inStream.close(); - } } } -- 2.39.5