You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2021/02/03 10:09:49 UTC

[flink] branch master updated: [FLINK-9844][client] PackagedProgram#close() closes ClassLoader

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

chesnay 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 3ff5361  [FLINK-9844][client] PackagedProgram#close() closes ClassLoader
3ff5361 is described below

commit 3ff536149d0134ea8e7fb74f0d383c5b1b09041e
Author: Chesnay Schepler <ch...@apache.org>
AuthorDate: Fri Jan 29 15:03:39 2021 +0100

    [FLINK-9844][client] PackagedProgram#close() closes ClassLoader
---
 .../java/org/apache/flink/client/program/PackagedProgram.java  |  8 +++++++-
 .../flink/runtime/webmonitor/handlers/JarSubmissionITCase.java | 10 ----------
 2 files changed, 7 insertions(+), 11 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 051a56d..e30f0c9 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
@@ -43,6 +43,7 @@ import java.lang.reflect.Modifier;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -89,7 +90,7 @@ public class PackagedProgram implements AutoCloseable {
 
     private final List<URL> classpaths;
 
-    private final ClassLoader userCodeClassLoader;
+    private final URLClassLoader userCodeClassLoader;
 
     private final SavepointRestoreSettings savepointSettings;
 
@@ -625,6 +626,11 @@ public class PackagedProgram implements AutoCloseable {
     @Override
     public void close() {
         try {
+            userCodeClassLoader.close();
+        } catch (IOException e) {
+            LOG.debug("Error while closing user-code classloader.", e);
+        }
+        try {
             deleteExtractedLibraries();
         } catch (Exception e) {
             LOG.debug("Error while deleting jars extracted from user-jar.", e);
diff --git a/flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/handlers/JarSubmissionITCase.java b/flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/handlers/JarSubmissionITCase.java
index 6fdd637..d209af4 100644
--- a/flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/handlers/JarSubmissionITCase.java
+++ b/flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/handlers/JarSubmissionITCase.java
@@ -22,12 +22,9 @@ import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.rest.messages.JobPlanInfo;
 import org.apache.flink.runtime.util.BlobServerResource;
 import org.apache.flink.runtime.webmonitor.TestingDispatcherGateway;
-import org.apache.flink.util.OperatingSystem;
 import org.apache.flink.util.TestLogger;
 
 import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -51,13 +48,6 @@ public class JarSubmissionITCase extends TestLogger {
 
     @Rule public final BlobServerResource blobServerResource = new BlobServerResource();
 
-    @BeforeClass
-    public static void checkOS() {
-        Assume.assumeFalse(
-                "This test fails on Windows due to unclosed JarFiles, see FLINK-9844.",
-                OperatingSystem.isWindows());
-    }
-
     @Test
     public void testJarSubmission() throws Exception {
         final TestingDispatcherGateway restfulGateway =