modules/jdk.packager/src/main/java/jdk/packager/builders/windows/WindowsAppImageBuilder.java

Print this page

        

@@ -54,10 +54,11 @@
 import java.util.Objects;
 import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Pattern;
+import java.util.stream.Stream;
 
 import static com.oracle.tools.packager.StandardBundlerParam.*;
 
 /**
  *

@@ -287,20 +288,21 @@
             throw new RuntimeException("Not found MSVC dlls");
         }
 
         AtomicReference<IOException> ioe = new AtomicReference<>();
         final String finalVsVer = vsVer;
-        Files.list(runtimeDir.resolve("bin"))
-                .filter(p -> Pattern.matches("msvc(r|p)\\d\\d\\d.dll", p.toFile().getName().toLowerCase()))
+        try (Stream<Path> files = Files.list(runtimeDir.resolve("bin"))) {
+            files.filter(p -> Pattern.matches("msvc(r|p)\\d\\d\\d.dll", p.toFile().getName().toLowerCase()))
                 .filter(p -> !p.toString().toLowerCase().endsWith(finalVsVer + ".dll"))
                 .forEach(p -> {
                     try {
                         Files.copy(p, root.resolve((p.toFile().getName())));
                     } catch (IOException e) {
                         ioe.set(e);
                     }
                 });
+        }
 
         IOException e = ioe.get();
         if (e != null) {
             throw e;
         }