public class ClassLoadingUtils extends Object
Constructor and Description |
---|
ClassLoadingUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> CompletableFuture<T> |
guardCompletionWithContextClassLoader(CompletableFuture<T> future,
ClassLoader contextClassLoader) |
static <T,E extends Throwable> |
runWithContextClassLoader(SupplierWithException<T,E> supplier,
ClassLoader contextClassLoader)
Runs the given supplier in a
TemporaryClassLoaderContext based on the given
classloader. |
static <T extends Throwable> |
runWithContextClassLoader(ThrowingRunnable<T> runnable,
ClassLoader contextClassLoader)
Runs the given runnable in a
TemporaryClassLoaderContext to prevent the plugin class
loader from leaking into Flink. |
static Executor |
withContextClassLoader(Executor executor,
ClassLoader contextClassLoader)
Wraps the given executor such that all submitted are runnables are run in a
TemporaryClassLoaderContext based on the given classloader. |
static Runnable |
withContextClassLoader(Runnable runnable,
ClassLoader contextClassLoader)
Wraps the given runnable in a
TemporaryClassLoaderContext to prevent the plugin class
loader from leaking into Flink. |
public static Runnable withContextClassLoader(Runnable runnable, ClassLoader contextClassLoader)
TemporaryClassLoaderContext
to prevent the plugin class
loader from leaking into Flink.runnable
- runnable to wrapcontextClassLoader
- class loader that should be set as the context class loaderpublic static Executor withContextClassLoader(Executor executor, ClassLoader contextClassLoader)
TemporaryClassLoaderContext
based on the given classloader.executor
- executor to wrapcontextClassLoader
- class loader that should be set as the context class loaderpublic static <T extends Throwable> void runWithContextClassLoader(ThrowingRunnable<T> runnable, ClassLoader contextClassLoader) throws T extends Throwable
TemporaryClassLoaderContext
to prevent the plugin class
loader from leaking into Flink.runnable
- runnable to runcontextClassLoader
- class loader that should be set as the context class loaderT extends Throwable
public static <T,E extends Throwable> T runWithContextClassLoader(SupplierWithException<T,E> supplier, ClassLoader contextClassLoader) throws E extends Throwable
TemporaryClassLoaderContext
based on the given
classloader.supplier
- supplier to runcontextClassLoader
- class loader that should be set as the context class loaderE extends Throwable
public static <T> CompletableFuture<T> guardCompletionWithContextClassLoader(CompletableFuture<T> future, ClassLoader contextClassLoader)
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.