This is an automated email from the ASF dual-hosted git repository.

philo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 54fa95690b [MINOR] Fix ZipFile resource leak in ResourceUtil (#11617)
54fa95690b is described below

commit 54fa95690b12c2d72da9a3878a0d8413e34f97b0
Author: Ankita Victor <[email protected]>
AuthorDate: Thu Feb 19 18:33:16 2026 +0530

    [MINOR] Fix ZipFile resource leak in ResourceUtil (#11617)
---
 .../java/org/apache/gluten/utils/ResourceUtil.java | 37 +++++++++-------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git 
a/gluten-core/src/main/java/org/apache/gluten/utils/ResourceUtil.java 
b/gluten-core/src/main/java/org/apache/gluten/utils/ResourceUtil.java
index 671fcc9aa6..80cc1fc9dd 100644
--- a/gluten-core/src/main/java/org/apache/gluten/utils/ResourceUtil.java
+++ b/gluten-core/src/main/java/org/apache/gluten/utils/ResourceUtil.java
@@ -101,31 +101,24 @@ public class ResourceUtil {
 
   private static void getResourcesFromJarFile(
       final File jarFile, final String dir, final Pattern pattern, final 
List<String> buffer) {
-    final ZipFile zf;
-    try {
-      zf = new ZipFile(jarFile);
+    try (ZipFile zf = new ZipFile(jarFile)) {
+      final Enumeration<? extends ZipEntry> e = zf.entries();
+      while (e.hasMoreElements()) {
+        final ZipEntry ze = e.nextElement();
+        final String fileName = ze.getName();
+        if (!fileName.startsWith(dir)) {
+          continue;
+        }
+        final String relativeFileName =
+            new File(dir).toURI().relativize(new 
File(fileName).toURI()).getPath();
+        final boolean accept = pattern.matcher(relativeFileName).matches();
+        if (accept) {
+          buffer.add(relativeFileName);
+        }
+      }
     } catch (final IOException e) {
       throw new GlutenException(e);
     }
-    final Enumeration<? extends ZipEntry> e = zf.entries();
-    while (e.hasMoreElements()) {
-      final ZipEntry ze = e.nextElement();
-      final String fileName = ze.getName();
-      if (!fileName.startsWith(dir)) {
-        continue;
-      }
-      final String relativeFileName =
-          new File(dir).toURI().relativize(new 
File(fileName).toURI()).getPath();
-      final boolean accept = pattern.matcher(relativeFileName).matches();
-      if (accept) {
-        buffer.add(relativeFileName);
-      }
-    }
-    try {
-      zf.close();
-    } catch (final IOException e1) {
-      throw new GlutenException(e1);
-    }
   }
 
   private static void getResourcesFromDirectory(


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

Reply via email to