final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware) throws IOException, HttpException {
for (int c = 1;; c++) {
final CloseableHttpResponse response = this.requestExecutor.execute(
route, request, context, execAware);
try {
if (this.retryStrategy.retryRequest(response, c, context)) {
response.close();
final long nextInterval = this.retryStrategy.getRetryInterval();
try {
this.log.trace("Wait for " + nextInterval);
Thread.sleep(nextInterval);
} catch (final InterruptedException e) {
throw new InterruptedIOException(e.getMessage());
}
} else {
return response;
}
} catch (final RuntimeException ex) {
response.close();
throw ex;
} catch (final IOException ex) {
response.close();
throw ex;
}
}
}