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

        Thread runner = startTask(task);

        while (testBlocker.getWaitersCount() < 1) {
            Thread.sleep(1L);
        }

        task.cancel(true);
        testBlocker.unblockExceptionally();

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

        runner.join();

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