Class DefaultBackoffStrategy

java.lang.Object
org.apache.hc.client5.http.impl.classic.DefaultBackoffStrategy
All Implemented Interfaces:
ConnectionBackoffStrategy

@Experimental public class DefaultBackoffStrategy extends Object implements ConnectionBackoffStrategy
This ConnectionBackoffStrategy backs off either for a raw network socket or connection timeout or if the server explicitly sends a 429 (Too Many Requests) or a 503 (Service Unavailable) response.
Since:
4.2
  • Constructor Details

    • DefaultBackoffStrategy

      public DefaultBackoffStrategy()
  • Method Details

    • shouldBackoff

      public boolean shouldBackoff(Throwable t)
      Description copied from interface: ConnectionBackoffStrategy
      Determines whether seeing the given Throwable as a result of request execution should result in a backoff signal.
      Specified by:
      shouldBackoff in interface ConnectionBackoffStrategy
      Parameters:
      t - the Throwable that happened
      Returns:
      true if a backoff signal should be given
    • shouldBackoff

      public boolean shouldBackoff(org.apache.hc.core5.http.HttpResponse response)
      Description copied from interface: ConnectionBackoffStrategy
      Determines whether receiving the given HttpResponse as a result of request execution should result in a backoff signal. Implementations MUST restrict themselves to examining the response header and MUST NOT consume any of the response body, if any.
      Specified by:
      shouldBackoff in interface ConnectionBackoffStrategy
      Parameters:
      response - the HttpResponse that was received
      Returns:
      true if a backoff signal should be given