class OAuthRefreshTokenOnFailProcessor extends OAuthRefreshTokenProcessor {

    @Override
    public void process(final Exchange exchange) throws Exception {
        final Exception caught = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
        if (caught instanceof HttpOperationFailedException) {
            final HttpOperationFailedException httpFailure = (HttpOperationFailedException) caught;
            LOG.warn("Failed invoking the remote API, status: {} {}, response body: {}", httpFailure.getStatusCode(),
                httpFailure.getStatusText(), httpFailure.getResponseBody());

            if (!shouldTryRefreshingAccessCode(httpFailure)) {
                throw httpFailure;
            }

            // we don't check the return value as we will throw `httpFailure`
            // anyhow
            tryToRefreshAccessToken();

            // we need to throw the failure so that the exchange fails,
            // otherwise it might be considered successful and we do not perform
            // any retry, and that would lead to data inconsistencies
            throw httpFailure;
        }

        super.process(exchange);
    }

      OAuthRefreshTokenOnFailProcessor(final OAuthState state, final Configuration configuration);

}