@ Override public final void initialize ( final HttpRequest request ) { request . setReadTimeout ( 2 * ONEMINITUES ) ; // 2 minutes read timeout final HttpUnsuccessfulResponseHandler backoffHandler = new HttpBackOffUnsuccessfulResponseHandler ( new ExponentialBackOff ( ) ) . setSleeper ( sleeper ) ; request . setInterceptor ( wrappedCredential ) ; request . setUnsuccessfulResponseHandler ( ( request1 , response , supportsRetry ) -> { if ( wrappedCredential . handleResponse ( request1 , response , supportsRetry ) ) { // If credential decides it can handle it, the return code or message indicated // something specific to authentication, and no backoff is desired. return true ; } else if ( backoffHandler . handleResponse ( request1 , response , supportsRetry ) ) { // Otherwise, we defer to the judgement of our internal backoff handler. LOG . info ( "Retrying " + request1 . getUrl ( ) . toString ( ) ) ; return true ; } else { return false ; } } ) ; request . setIOExceptionHandler ( new HttpBackOffIOExceptionHandler ( new ExponentialBackOff ( ) ) . setSleeper ( sleeper ) ) ; }
Initializes the given request .