@Override
    public void close() throws Exception {
        if (closed.compareAndSet(false, true)) {
            disposer.run();
        }
    }
@Test
    void testCloseIsIdempotent() throws Exception {
        final CountingCloseable disposer = new CountingCloseable();
        final OpaqueMemoryResource<Object> resource =
                new OpaqueMemoryResource<>(new Object(), 10, disposer);

        resource.close();
        resource.close();

        assertThat(disposer.count).isOne();
    }