@Override
    public final Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
        try {
            synchronized (getClassLoadingLock(name)) {
                return loadClassWithoutExceptionHandling(name, resolve);
            }
        } catch (Throwable classLoadingException) {
            classLoadingExceptionHandler.accept(classLoadingException);
            throw classLoadingException;
        }
    }
@Test
    void testExceptionHandling() {
        RuntimeException expectedException = new RuntimeException("Expected exception");
        AtomicReference<Throwable> handledException = new AtomicReference<>();

        assertThatThrownBy(
                        () -> {
                            try (FlinkUserCodeClassLoader classLoaderWithErrorHandler =
                                    new ThrowingURLClassLoader(
                                            handledException::set, expectedException)) {
                                classLoaderWithErrorHandler.loadClass("dummy.class");
                            }
                        })
                .isSameAs(expectedException);

        assertThat(handledException.get()).isSameAs(expectedException);
    }