public HttpResponse tryMany(HttpRequest httpRequest) throws HttpRequestException {
  int numTries=0;
  long startTime=System.currentTimeMillis();
  HttpResponse res=null;
  while (numTries < maxRetries) {
    try {
      setConnectionTimeout(getNextTimeout(numTries));
      if (requestLogger.isLoggingEnabled()) {
        requestLogger.log((numTries + 1) + "of" + maxRetries+ ", trying "+ httpRequest.getPath());
      }
      startTime=System.currentTimeMillis();
      res=doHttpMethod(httpRequest.getPath(),httpRequest.getHttpMethod(),httpRequest.getContentType(),httpRequest.getContent());
      if (res != null) {
        return res;
      }
    }
 catch (    HttpRequestException e) {
      if (isTimeoutException(e,startTime) && numTries < (maxRetries - 1)) {
      }
 else {
        boolean isRecoverable=requestHandler.onError(e);
        if (isRecoverable && numTries < (maxRetries - 1)) {
          try {
            Thread.sleep(connectionTimeout);
          }
 catch (          InterruptedException ie) {
            throw e;
          }
        }
 else {
          throw e;
        }
      }
    }
    numTries++;
  }
  return null;
}

public HttpResponse tryMany ( HttpRequest httpRequest ) throws HttpRequestException { int numTries = 0 ; long startTime = System . currentTimeMillis ( ) ; HttpResponse res = null ; while ( numTries < maxRetries ) { try { setConnectionTimeout ( getNextTimeout ( numTries ) ) ; if ( requestLogger . isLoggingEnabled ( ) ) { requestLogger . log ( ( numTries + 1 ) + "of" + maxRetries + ", trying " + httpRequest . getPath ( ) ) ; } startTime = System . currentTimeMillis ( ) ; res = doHttpMethod ( httpRequest . getPath ( ) , httpRequest . getHttpMethod ( ) , httpRequest . getContentType ( ) , httpRequest . getContent ( ) ) ; if ( res != null ) { return res ; } } catch ( HttpRequestException e ) { if ( isTimeoutException ( e , startTime ) && numTries < ( maxRetries - 1 ) ) { } else { boolean isRecoverable = requestHandler . onError ( e ) ; if ( isRecoverable && numTries < ( maxRetries - 1 ) ) { try { Thread . sleep ( connectionTimeout ) ; } catch ( InterruptedException ie ) { throw e ; } } else { throw e ; } } } numTries ++ ; } return null ; }
tries several times until successful or maxretries exhausted . must throw exception in order for the async process to forward it to the callback ' s onerror method .
