1 package org.openecomp.sdc.common.http.client.api;
3 import org.apache.http.protocol.HttpContext;
4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory;
7 import java.io.IOException;
9 public class RetryHandlers {
11 private static final Logger LOGGER = LoggerFactory.getLogger(RetryHandlers.class);
13 private RetryHandlers(){}
15 public static ComparableHttpRequestRetryHandler getDefault(int numOfRetries) {
16 return (IOException exception, int executionCount, HttpContext context) -> {
17 LOGGER.debug("failed sending request with exception", exception);
18 LOGGER.debug("try request number: {}", executionCount);
19 return executionCount <= numOfRetries;