code: public boolean shouldRetry(int previousAttempts, long totalElapsedTimeMillis, HttpResponse response) {
          String contentType = response.getEntity().getContentType();
          if (contentType != null && !contentType.startsWith(JSON_MIME_TYPE)) {
              // it's not JSON; don't even try to parse it
              return false;
          }
          Error error;
          try {
              error = jsonSerializer.deserialize(Error.class, response.getEntity().getContent());
          }
          catch (IOException e) {
              return false;
          }
          switch(error.getErrorCode()) {
              case 4001: /** Smartsheet.com is currently offline for system maintenance. Please check back again shortly. */
              case 4002: /** Server timeout exceeded. Request has failed */
              case 4003: /** Rate limit exceeded. */
              case 4004: /** An unexpected error has occurred. Please retry your request.
               * If you encounter this error repeatedly, please contact api@smartsheet.com for assistance. */
                  break;
              default:
                  return false;
          }
  
          long backoffMillis = calcBackoff(previousAttempts, totalElapsedTimeMillis, error);
          if(backoffMillis < 0)
              return false;
  
          logger.info("HttpError StatusCode=" + response.getStatusCode() + ": Retrying in " + backoffMillis + " milliseconds");
          try {
              Thread.sleep(backoffMillis);
          }
          catch (InterruptedException e) {
              logger.warn("sleep interrupted", e);
              return false;
          }
          return true;
      }
docs: Called when an API request fails to determine if it can retry the request.
  Calls calcBackoff to determine the time to wait in between retries.
  
  @param previousAttempts number of attempts (including this one) to execute request
  @param totalElapsedTimeMillis total time spent in millis for all previous (and this) attempt
  @param response the failed HttpResponse
  @return true if this request can be retried