Class ClassLoadingUtils


  • public class ClassLoadingUtils
    extends Object
    Classloading utilities.
    • Constructor Detail

      • ClassLoadingUtils

        public ClassLoadingUtils()
    • Method Detail

      • withContextClassLoader

        public static Runnable withContextClassLoader​(Runnable runnable,
                                                      ClassLoader contextClassLoader)
        Wraps the given runnable in a TemporaryClassLoaderContext to prevent the plugin class loader from leaking into Flink.
        Parameters:
        runnable - runnable to wrap
        contextClassLoader - 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 a TemporaryClassLoaderContext based on the given classloader.
        Parameters:
        executor - executor to wrap
        contextClassLoader - 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 a TemporaryClassLoaderContext to prevent the plugin class loader from leaking into Flink.
        Parameters:
        runnable - runnable to run
        contextClassLoader - 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 a TemporaryClassLoaderContext based on the given classloader.
        Parameters:
        supplier - supplier to run
        contextClassLoader - class loader that should be set as the context class loader
        Throws:
        E extends Throwable