@Test public void executeShouldCancelAllIfDelegateThrowUnexpectedException() throws Exception { Exception expected = mock(Exception.class); when(mockRequestExecutor.execute(request)).thenThrow(expected); try { toTest.execute(request); } catch (Exception e) { assertSame(expected, e); } }
public Response execute(Request request) throws Exception { RetryHandler retryHandler = request.getMethodConfig().getRetryHandler(); RequestException exception = null; Response response; int attemptCount = 1; do { Disposables.dispose(exception); response = null; try { response = delegate.execute(request); if(response.getStatusCode() >= minErrorStatusCode) { exception = new RequestException("Request failed - status code: " + response.getStatusCode(), response); }else{ return response; } } catch (RequestException e) { exception = e; } }while(retryHandler.retry(exception, ++attemptCount)); if(response != null) { return response; } throw exception; }
RetryingRequestExecutor implements RequestExecutor { public Response execute(Request request) throws Exception { RetryHandler retryHandler = request.getMethodConfig().getRetryHandler(); RequestException exception = null; Response response; int attemptCount = 1; do { Disposables.dispose(exception); response = null; try { response = delegate.execute(request); if(response.getStatusCode() >= minErrorStatusCode) { exception = new RequestException("Request failed - status code: " + response.getStatusCode(), response); }else{ return response; } } catch (RequestException e) { exception = e; } }while(retryHandler.retry(exception, ++attemptCount)); if(response != null) { return response; } throw exception; } }
RetryingRequestExecutor implements RequestExecutor { public Response execute(Request request) throws Exception { RetryHandler retryHandler = request.getMethodConfig().getRetryHandler(); RequestException exception = null; Response response; int attemptCount = 1; do { Disposables.dispose(exception); response = null; try { response = delegate.execute(request); if(response.getStatusCode() >= minErrorStatusCode) { exception = new RequestException("Request failed - status code: " + response.getStatusCode(), response); }else{ return response; } } catch (RequestException e) { exception = e; } }while(retryHandler.retry(exception, ++attemptCount)); if(response != null) { return response; } throw exception; } RetryingRequestExecutor(RequestExecutor delegate, int minErrorStatusCode); }
RetryingRequestExecutor implements RequestExecutor { public Response execute(Request request) throws Exception { RetryHandler retryHandler = request.getMethodConfig().getRetryHandler(); RequestException exception = null; Response response; int attemptCount = 1; do { Disposables.dispose(exception); response = null; try { response = delegate.execute(request); if(response.getStatusCode() >= minErrorStatusCode) { exception = new RequestException("Request failed - status code: " + response.getStatusCode(), response); }else{ return response; } } catch (RequestException e) { exception = e; } }while(retryHandler.retry(exception, ++attemptCount)); if(response != null) { return response; } throw exception; } RetryingRequestExecutor(RequestExecutor delegate, int minErrorStatusCode); Response execute(Request request); }
RetryingRequestExecutor implements RequestExecutor { public Response execute(Request request) throws Exception { RetryHandler retryHandler = request.getMethodConfig().getRetryHandler(); RequestException exception = null; Response response; int attemptCount = 1; do { Disposables.dispose(exception); response = null; try { response = delegate.execute(request); if(response.getStatusCode() >= minErrorStatusCode) { exception = new RequestException("Request failed - status code: " + response.getStatusCode(), response); }else{ return response; } } catch (RequestException e) { exception = e; } }while(retryHandler.retry(exception, ++attemptCount)); if(response != null) { return response; } throw exception; } RetryingRequestExecutor(RequestExecutor delegate, int minErrorStatusCode); Response execute(Request request);  }