private <T, E extends Exception> T withClassLoader(StorageAction<T, E> action) throws E {
        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(loader);
        try {
            return action.execute();
        } finally {
            Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
    }
@Test
    public void testWithClassLoader() throws RemoteStorageException {
        DummyClassLoader dummyClassLoader = new DummyClassLoader();
        RemoteLogMetadataManager delegate = mock(RemoteLogMetadataManager.class);
        ClassLoaderAwareRemoteLogMetadataManager rlmm = new ClassLoaderAwareRemoteLogMetadataManager(delegate, dummyClassLoader);
        when(delegate.addRemoteLogSegmentMetadata(any(RemoteLogSegmentMetadata.class))).thenAnswer(metadata -> {
            assertEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader());
            return CompletableFuture.completedFuture(null);
        });
        assertNotEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader());
        rlmm.addRemoteLogSegmentMetadata(mock(RemoteLogSegmentMetadata.class));
        assertNotEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader());
    }