@@ -0,0 +1,1649 @@
+package com.mv.hr.client;%0A%0Aimport org.apache.log4j.Logger;%0A%0Aimport com.mv.base.exception.ThirdPartyBadResponseException;%0Aimport com.mv.base.exception.ThirdPartyConnectivityFailureException;%0A%0A/**%0A * Retries synchronously an http action when it fails%0A */%0Apublic class RetryHttpActionExecutor %7B%0A%09private static final Logger LOG = Logger.getLogger(RetryHttpActionExecutor.class);%0A%0A%09private int tries;%0A%09private int maxTries;%0A%09private long millisecondsBetweenTries;%0A%0A%09public RetryHttpActionExecutor(int maxTries, long millisecondsBetweenTries) %7B%0A%09%09this.maxTries = maxTries;%0A%09%09this.millisecondsBetweenTries = millisecondsBetweenTries;%0A%09%7D%0A%0A%09public %3CT%3E T execute(HttpActionPerformer actionPerformer, Class%3CT%3E resultClass)%0A%09%09%09throws ThirdPartyBadResponseException, ThirdPartyConnectivityFailureException %7B%0A%0A%09%09tries++;%0A%0A%09%09try %7B%0A%09%09%09return actionPerformer.getResponse(resultClass);%0A%09%09%7D catch (ThirdPartyBadResponseException %7C ThirdPartyConnectivityFailureException e) %7B%0A%09%09%09if (tries == maxTries) %7B%0A%09%09%09%09throw e;%0A%09%09%09%7D%0A%0A%09%09%09LOG.warn(actionPerformer.getUrlPath() + %22 failed. About to try again for %22 + (tries + 1) + %22 out of %22 + maxTries + %22 times...%22);%0A%0A%09%09%09try %7B%0A%09%09%09%09Thread.sleep(millisecondsBetweenTries);%0A%09%09%09%7D catch (InterruptedException ie) %7B%0A%09%09%09%09LOG.error(%22Thread has been asked to interrupt while waiting between retries. Returning null as a response.%22, ie);%0A%09%09%09%09Thread.currentThread().interrupt(); // Restore the interrupted status of the thread%0A%09%09%09%09return null;%0A%09%09%09%7D%0A%0A%09%09%09LOG.debug(%22After waiting %22 + millisecondsBetweenTries + %22 ms %22 + actionPerformer.getUrlPath() + %22 is about to be performed...%22);%0A%0A%09%09%09return execute(actionPerformer, resultClass);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add executor to retry calls synchronously upon failure