paul8263 commented on a change in pull request #15927:
URL: https://github.com/apache/flink/pull/15927#discussion_r638418295



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/FlinkUserCodeClassLoadersTest.java
##########
@@ -208,6 +212,64 @@ public void testRepeatedParentFirstPatternClass() throws 
Exception {
         childClassLoader.close();
     }
 
+    @Test
+    public void testGetClassLoaderInfo() {
+        final String className = FlinkUserCodeClassLoadersTest.class.getName();
+        final String parentFirstPattern = className.substring(0, 
className.lastIndexOf('.'));
+
+        final ClassLoader parentClassLoader = getClass().getClassLoader();
+
+        final URL childCodePath = 
getClass().getProtectionDomain().getCodeSource().getLocation();
+
+        final URLClassLoader childClassLoader =
+                FlinkUserCodeClassLoaders.childFirst(
+                        new URL[] {childCodePath},
+                        parentClassLoader,
+                        new String[] {parentFirstPattern},
+                        NOOP_EXCEPTION_HANDLER,
+                        true);
+
+        String formattedURL = null;
+        try {
+            formattedURL = ClassLoaderUtil.formatURL(childCodePath);
+        } catch (IOException e) {
+            // Should not fail here
+            fail();
+        }
+
+        assertEquals(
+                ClassLoaderUtil.getUserCodeClassLoaderInfo(childClassLoader),
+                "URL ClassLoader:" + formattedURL);
+    }
+
+    @Test
+    public void testGetClassLoaderInfoWithClassLoaderClosed() {
+        final String className = FlinkUserCodeClassLoadersTest.class.getName();
+        final String parentFirstPattern = className.substring(0, 
className.lastIndexOf('.'));
+
+        final ClassLoader parentClassLoader = getClass().getClassLoader();
+
+        final URL childCodePath = 
getClass().getProtectionDomain().getCodeSource().getLocation();
+
+        final URLClassLoader childClassLoader =
+                FlinkUserCodeClassLoaders.childFirst(
+                        new URL[] {childCodePath},
+                        parentClassLoader,
+                        new String[] {parentFirstPattern},
+                        NOOP_EXCEPTION_HANDLER,
+                        true);
+
+        try {
+            childClassLoader.close();
+        } catch (IOException e) {
+            fail("Cannot close child classloader");
+        }

Review comment:
       It was fixed in c927703




-- 
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.

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


Reply via email to