public <R, X extends Exception> R withHandle(HandleCallback<R, X> callback) throws X {
        final HandleCallback<R, X> decoratedCallback = handleCallbackDecorator.get().decorate(callback);

        final var handleSupplier = handleScope.get();
        if (handleSupplier != null) {
            return decoratedCallback.withHandle(handleSupplier.getHandle());
        }

        try (Handle h = this.open()) {
            SqlStatements sqlStatements = h.getConfig(SqlStatements.class);
            sqlStatements.setAttachAllStatementsForCleanup(sqlStatements.isAttachCallbackStatementsForCleanup());

            handleScope.set(ConstantHandleSupplier.of(h));
            return decoratedCallback.withHandle(h);
        } finally {
            handleScope.clear();
        }
    }
A convenience function which manages the lifecycle of a handle and yields it to a callback
for use by clients.

@param callback A callback which will receive an open Handle
@param <R> type returned by the callback
@param <X> exception type thrown by the callback, if any.

@return the value returned by callback

@throws X any exception thrown by the callback
core/src/main/java/org/jdbi/v3/core/Jdbi.java