@Override
    public boolean authorize(P principal, String role, @Nullable ContainerRequestContext requestContext) {
        try (Timer.Context context = getsTimer.time()) {
            final AuthorizationContext<P> cacheKey = getAuthorizationContext(principal, role, requestContext);
            return Boolean.TRUE.equals(cache.get(cacheKey));
        } catch (CompletionException e) {
            Throwable cause = e.getCause();
            if (cause instanceof RuntimeException) {
                throw (RuntimeException) cause;
            }
            if (cause instanceof Error) {
                throw (Error) cause;
            }
            throw e;
        }
    }
@Test
    void cachesTheFirstReturnedPrincipal() throws Exception {
        assertThat(cached.authorize(principal, role, requestContext)).isTrue();
        assertThat(cached.authorize(principal, role, requestContext)).isTrue();

        verify(underlying, times(1)).authorize(principal, role, requestContext);
    }