@VisibleForTesting
    protected void cancel() {
        closeSnapshotIO();
        if (resourceCleanupOwnershipTaken.compareAndSet(false, true)) {
            cleanup();
        }
    }
@Test
    void testCancelBeforeRun() throws Exception {

        task.cancel(true);

        Thread runner = startTask(task);

        assertThatThrownBy(task::get).isInstanceOf(CancellationException.class);

        runner.join();

        assertThat(testAsyncSnapshotCallable.getInvocationOrder())
                .containsExactly(METHOD_CANCEL, METHOD_CLEANUP);
        assertThat(testProvidedResource.isClosed()).isTrue();
    }