zentol commented on a change in pull request #15927:
URL: https://github.com/apache/flink/pull/15927#discussion_r635900027
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/FlinkUserCodeClassLoadersTest.java
##########
@@ -208,6 +212,50 @@ public void testRepeatedParentFirstPatternClass() throws
Exception {
childClassLoader.close();
}
+ @Test
+ public void testGetClassLoaderInfo() throws Exception {
+ final ClassLoader parentClassLoader = getClass().getClassLoader();
+
+ final URL childCodePath =
getClass().getProtectionDomain().getCodeSource().getLocation();
+
+ final URLClassLoader childClassLoader =
+ FlinkUserCodeClassLoaders.childFirst(
+ new URL[] {childCodePath},
+ parentClassLoader,
+ new String[] {},
+ NOOP_EXCEPTION_HANDLER,
+ true);
+
+ String formattedURL = ClassLoaderUtil.formatURL(childCodePath);
+
+ assertEquals(
+ ClassLoaderUtil.getUserCodeClassLoaderInfo(childClassLoader),
+ "URL ClassLoader:" + formattedURL);
+
+ childClassLoader.close();
+ }
+
+ @Test
+ public void testGetClassLoaderInfoWithClassLoaderClosed() throws Exception
{
+ final ClassLoader parentClassLoader = getClass().getClassLoader();
+
+ final URL childCodePath =
getClass().getProtectionDomain().getCodeSource().getLocation();
+
+ final URLClassLoader childClassLoader =
+ FlinkUserCodeClassLoaders.childFirst(
+ new URL[] {childCodePath},
+ parentClassLoader,
+ new String[] {},
+ NOOP_EXCEPTION_HANDLER,
+ true);
+
+ childClassLoader.close();
+
+ assertThat(
+ ClassLoaderUtil.getUserCodeClassLoaderInfo(childClassLoader),
+ is(startsWith("Cannot access classloader info due to an
exception.")));
Review comment:
```suggestion
startsWith("Cannot access classloader info due to an
exception."));
```
I would think that `is` isn't necessary.
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/FlinkUserCodeClassLoadersTest.java
##########
@@ -208,6 +212,50 @@ public void testRepeatedParentFirstPatternClass() throws
Exception {
childClassLoader.close();
}
+ @Test
+ public void testGetClassLoaderInfo() throws Exception {
+ final ClassLoader parentClassLoader = getClass().getClassLoader();
+
+ final URL childCodePath =
getClass().getProtectionDomain().getCodeSource().getLocation();
+
+ final URLClassLoader childClassLoader =
+ FlinkUserCodeClassLoaders.childFirst(
+ new URL[] {childCodePath},
+ parentClassLoader,
+ new String[] {},
+ NOOP_EXCEPTION_HANDLER,
+ true);
+
+ String formattedURL = ClassLoaderUtil.formatURL(childCodePath);
+
+ assertEquals(
+ ClassLoaderUtil.getUserCodeClassLoaderInfo(childClassLoader),
+ "URL ClassLoader:" + formattedURL);
+
+ childClassLoader.close();
Review comment:
if you want to ensure that this CL is closed then you should use a
finally block to ensure it is closed if the test fails
--
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]