@Override
    public void cleanableRemoved(StatementContext statementContext, Cleanable cleanable) {
        requireNonNull(statementContext, "statementContext is null!");
        requireNonNull(cleanable, "cleanable is null");

        assertTrue(contextElements.containsKey(statementContext),
            () -> format("statement context %s is unknown", statementContext));

        RecordingContext<Cleanable> context = contextElements.get(statementContext);

        assertTrue(context.objectAdded.containsKey(cleanable),
            () -> format("cleanable %s is unknown", cleanable));
        assertFalse(context.objectRemoved.containsKey(cleanable),
            () -> format("cleanable %s has already been removed by thread %s", cleanable, context.objectRemoved.get(cleanable)));

        context.objectRemoved.putIfAbsent(cleanable, getThreadName());
    }
A simple leak checker that tracks statement context and cleanable resource management.
testing/src/main/java/org/jdbi/v3/testing/junit5/internal/JdbiLeakChecker.java