You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by fa...@apache.org on 2025/03/26 02:45:25 UTC

(flink) branch master updated: [hotfix][clients] Refactor PackagedProgram#getJobJarAndDependencies to reduce some redundant lines. (#26238)

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

fanrui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new c6c90b8a3a5 [hotfix][clients] Refactor PackagedProgram#getJobJarAndDependencies to reduce some redundant lines. (#26238)
c6c90b8a3a5 is described below

commit c6c90b8a3a5fea3c345ec3666801ccec7656c653
Author: Yuepeng Pan <fl...@126.com>
AuthorDate: Wed Mar 26 10:45:18 2025 +0800

    [hotfix][clients] Refactor PackagedProgram#getJobJarAndDependencies to reduce some redundant lines. (#26238)
    
    Co-authored-by: Rui Fan <19...@gmail.com>
---
 .../flink/client/program/PackagedProgram.java      | 29 ++++++----------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java b/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java
index f2bdb9a2e3e..af1be294d07 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java
@@ -246,7 +246,12 @@ public class PackagedProgram implements AutoCloseable {
 
     /** Returns all provided libraries needed to run the program. */
     public List<URL> getJobJarAndDependencies() {
-        List<URL> libs = new ArrayList<URL>(extractedTempLibraries.size() + 1);
+        return getJobJarAndDependencies(jarFile, extractedTempLibraries, isPython);
+    }
+
+    private static List<URL> getJobJarAndDependencies(
+            URL jarFile, List<File> extractedTempLibraries, boolean isPython) {
+        List<URL> libs = new ArrayList<>(extractedTempLibraries.size() + 2);
 
         if (jarFile != null) {
             libs.add(jarFile);
@@ -258,11 +263,9 @@ public class PackagedProgram implements AutoCloseable {
                 throw new RuntimeException("URL is invalid. This should not happen.", e);
             }
         }
-
         if (isPython) {
             libs.add(PackagedProgramUtils.getPythonJar());
         }
-
         return libs;
     }
 
@@ -276,24 +279,8 @@ public class PackagedProgram implements AutoCloseable {
                         ? Collections.emptyList()
                         : extractContainedLibraries(jarFileUrl);
 
-        List<URL> libs = new ArrayList<URL>(extractedTempLibraries.size() + 1);
-
-        if (jarFileUrl != null) {
-            libs.add(jarFileUrl);
-        }
-        for (File tmpLib : extractedTempLibraries) {
-            try {
-                libs.add(tmpLib.getAbsoluteFile().toURI().toURL());
-            } catch (MalformedURLException e) {
-                throw new RuntimeException("URL is invalid. This should not happen.", e);
-            }
-        }
-
-        if (isPython(entryPointClassName)) {
-            libs.add(PackagedProgramUtils.getPythonJar());
-        }
-
-        return libs;
+        return getJobJarAndDependencies(
+                jarFileUrl, extractedTempLibraries, isPython(entryPointClassName));
     }
 
     /** Deletes all temporary files created for contained packaged libraries. */