Class ClassLoadingUtils
- java.lang.Object
-
- org.apache.flink.runtime.concurrent.ClassLoadingUtils
-
public class ClassLoadingUtils extends Object
Classloading utilities.
-
-
Constructor Summary
Constructors Constructor Description ClassLoadingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> CompletableFuture<T>guardCompletionWithContextClassLoader(CompletableFuture<T> future, ClassLoader contextClassLoader)static <T,E extends Throwable>
TrunWithContextClassLoader(org.apache.flink.util.function.SupplierWithException<T,E> supplier, ClassLoader contextClassLoader)Runs the given supplier in aTemporaryClassLoaderContextbased on the given classloader.static <T extends Throwable>
voidrunWithContextClassLoader(org.apache.flink.util.function.ThrowingRunnable<T> runnable, ClassLoader contextClassLoader)Runs the given runnable in aTemporaryClassLoaderContextto prevent the plugin class loader from leaking into Flink.static RunnablewithContextClassLoader(Runnable runnable, ClassLoader contextClassLoader)Wraps the given runnable in aTemporaryClassLoaderContextto prevent the plugin class loader from leaking into Flink.static ExecutorwithContextClassLoader(Executor executor, ClassLoader contextClassLoader)Wraps the given executor such that all submitted are runnables are run in aTemporaryClassLoaderContextbased on the given classloader.
-
-
-
Method Detail
-
withContextClassLoader
public static Runnable withContextClassLoader(Runnable runnable, ClassLoader contextClassLoader)
Wraps the given runnable in aTemporaryClassLoaderContextto prevent the plugin class loader from leaking into Flink.- Parameters:
runnable- runnable to wrapcontextClassLoader- class loader that should be set as the context class loader- Returns:
- wrapped runnable
-
withContextClassLoader
public static Executor withContextClassLoader(Executor executor, ClassLoader contextClassLoader)
Wraps the given executor such that all submitted are runnables are run in aTemporaryClassLoaderContextbased on the given classloader.- Parameters:
executor- executor to wrapcontextClassLoader- class loader that should be set as the context class loader- Returns:
- wrapped executor
-
runWithContextClassLoader
public static <T extends Throwable> void runWithContextClassLoader(org.apache.flink.util.function.ThrowingRunnable<T> runnable, ClassLoader contextClassLoader) throws T extends Throwable
Runs the given runnable in aTemporaryClassLoaderContextto prevent the plugin class loader from leaking into Flink.- Parameters:
runnable- runnable to runcontextClassLoader- class loader that should be set as the context class loader- Throws:
T extends Throwable
-
runWithContextClassLoader
public static <T,E extends Throwable> T runWithContextClassLoader(org.apache.flink.util.function.SupplierWithException<T,E> supplier, ClassLoader contextClassLoader) throws E extends Throwable
Runs the given supplier in aTemporaryClassLoaderContextbased on the given classloader.- Parameters:
supplier- supplier to runcontextClassLoader- class loader that should be set as the context class loader- Throws:
E extends Throwable
-
guardCompletionWithContextClassLoader
public static <T> CompletableFuture<T> guardCompletionWithContextClassLoader(CompletableFuture<T> future, ClassLoader contextClassLoader)
-
-