class AccessTokenProvider {

    protected synchronized CompletableFuture<AccessToken> obtainAccessToken() {
        // The variable is needed to make sure that always a non-null result is
        // returned; even if whenComplete() runs in the same thread.
        CompletableFuture<AccessToken> result = tokenFuture;
        if (tokenFuture == null) {
            LOG.debug("Obtaining a new access token for SW360.");
            tokenFuture = result = getAuthClient().getOAuth2AccessToken()
                    .thenApply(AccessToken::new);
            tokenFuture.whenComplete(this::handleTokenResult);
        }

        return result;
    }

    public  AccessTokenProvider(SW360AuthenticationClient authClient);

}