Code example for Callable

Methods: call

0
        } 
    } 
 
    public <T> T callAs(final Authentication auth, final Callable<T> task) throws Exception {
        checkNotNull(auth);
        checkNotNull(task);
        final SecurityContext ctx = SecurityContextHolder.getContext();
        final Authentication current = ctx.getAuthentication();
        ctx.setAuthentication(auth);
        try { 
            return task.call();
        } 
        finally { 
            ctx.setAuthentication(current);
        } 
    } 
 
    public <T> T callAs2(final Authentication auth, final Callable<T> task) {
        try { 
            return callAs(auth, task);
Experience pair programming with AI  Get Codota for Java