public static <T> T with(HttpRequest request, Callable<T> callable) throws Exception {
        HttpRequest existing = REQUEST.get();
        boolean isSet = false;
        try {
            if (request != existing) {
                isSet = true;
                REQUEST.set(request);
            }
            return callable.call();
        } finally {
            if (isSet) {
                REQUEST.remove();
            }
        }
    }
public static < T > T with ( HttpRequest request , Callable < T > callable ) throws Exception { HttpRequest existing = REQUEST . get ( ) ; boolean isSet = false ; try { if ( request != existing ) { isSet = true ; REQUEST . set ( request ) ; } return callable . call ( ) ; } finally { if ( isSet ) { REQUEST . remove ( ) ; } } }
Wrap the execution of the given callable in request context processing.

@param request  The request
@param callable The callable
@param <T>      The return type of the callable
@return The return value of the callable
@throws Exception If the callable throws an exception