pepness commented on code in PR #7076:
URL: https://github.com/apache/netbeans/pull/7076#discussion_r1498498198


##########
java/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java:
##########
@@ -1048,24 +1046,21 @@ private File checkAvailability(String ver, VersionRange 
vr, InputOutput ioput) {
                     LOGGER.log(Level.WARNING, "wasn''t able to download maven 
binaries, version {0}", ver);
                     return null;
                 }
-                str = new ZipInputStream(is);
-                ZipEntry entry;
-                while ((entry = str.getNextEntry()) != null) {
-                    //base it of f not child as the zip contains the maven 
base folder
-                    File fileOrDir = new File(f,  entry.getName());
-                    if (entry.isDirectory()) {
-                        fileOrDir.mkdirs();
-                    } else {
-                        FileOutputStream fos = null;
-                        try {
-                            fos = new FileOutputStream(fileOrDir);
-                            FileUtil.copy(str, fos);
-                        } finally {
-                            IOUtil.close(fos);
-                        }
-                        // correct way to set executable flag?
-                        if ("bin".equals(fileOrDir.getParentFile().getName()) 
&& !fileOrDir.getName().endsWith(".conf")) {
-                            fileOrDir.setExecutable(true);
+                try (ZipInputStream str = new ZipInputStream(is)) {
+                    ZipEntry entry;
+                    while ((entry = str.getNextEntry()) != null) {
+                        //base it of f not child as the zip contains the maven 
base folder
+                        File fileOrDir = new File(f,  entry.getName());
+                        if (entry.isDirectory()) {
+                            fileOrDir.mkdirs();
+                        } else {
+                            try (FileOutputStream fos = new 
FileOutputStream(fileOrDir)) {
+                                FileUtil.copy(str, fos);
+                            }

Review Comment:
   `FileUtil.copy` -> `Files.copy()` will have another cleanup PR. Good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to