public <R, E, X extends Exception> R withExtension(Class<E> extensionType, ExtensionCallback<R, E, X> callback)
            throws X {
        final var handleSupplier = handleScope.get();
        if (handleSupplier != null) {
            return callWithExtension(extensionType, callback, handleSupplier);
        }

        try (LazyHandleSupplier lazyHandleSupplier = new LazyHandleSupplier(this)) {
            handleScope.set(lazyHandleSupplier);
            return callWithExtension(extensionType, callback, lazyHandleSupplier);
        } finally {
            handleScope.clear();
        }
    }
A convenience method which opens an extension of the given type, yields it to a callback, and returns the result
of the callback. A handle is opened if needed by the extension, and closed before returning to the caller.

@param extensionType the type of extension.
@param callback      a callback which will receive the extension.
@param <R> the return type
@param <E> the extension type
@param <X> the exception type optionally thrown by the callback
@return the value returned by the callback.
@throws NoSuchExtensionException if no {@link ExtensionFactory} is registered which supports the given extension
                                 type.
@throws X                        if thrown by the callback.
core/src/main/java/org/jdbi/v3/core/Jdbi.java