public static <T> CompletableFuture<T> guardCompletionWithContextClassLoader(
            CompletableFuture<T> future, ClassLoader contextClassLoader) {
        final CompletableFuture<T> guardedFuture = new CompletableFuture<>();
        future.whenComplete(
                (value, throwable) ->
                        runWithContextClassLoader(
                                () -> FutureUtils.doForward(value, throwable, guardedFuture),
                                contextClassLoader));
        return guardedFuture;
    }
@Test
    void testGuardCompletionWithContextClassLoader() throws Exception {
        final CompletableFuture<Void> originalFuture = new CompletableFuture<>();

        final CompletableFuture<Void> guardedFuture =
                ClassLoadingUtils.guardCompletionWithContextClassLoader(
                        originalFuture, TEST_CLASS_LOADER);

        final CompletableFuture<ClassLoader> contextClassLoader =
                guardedFuture.thenApply(ignored -> Thread.currentThread().getContextClassLoader());

        originalFuture.complete(null);
        assertThat(contextClassLoader.get()).isSameAs(TEST_CLASS_LOADER);
    }