Class NvdApiRetryStrategy

java.lang.Object
org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
io.github.jeremylong.openvulnerability.client.nvd.NvdApiRetryStrategy
All Implemented Interfaces:
org.apache.hc.client5.http.HttpRequestRetryStrategy

public class NvdApiRetryStrategy extends org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
Implements a back-off delay retry strategy that honors the retry-after header.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long
    Retry interval between subsequent retries in milliseconds.
    private static final org.slf4j.Logger
    Reference to the logger.
    private final int
    Maximum number of allowed retries.
    private static final String
     

    Fields inherited from class org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy

    INSTANCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    NvdApiRetryStrategy(int maxRetries, long delay)
    Constructs a new NVD API retry strategy.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.hc.core5.util.TimeValue
    getRetryInterval(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
     
    private void
    logRetryState(org.apache.hc.core5.http.HttpRequest request, IOException exception, int execCount)
     
    boolean
    retryRequest(org.apache.hc.core5.http.HttpRequest request, IOException exception, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
     
    boolean
    retryRequest(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
     
    static String
    toOrdinal(int number)
    Converts a number to an ordinal string.

    Methods inherited from class org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy

    handleAsIdempotent

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.hc.client5.http.HttpRequestRetryStrategy

    getRetryInterval
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
      Reference to the logger.
    • maxRetries

      private final int maxRetries
      Maximum number of allowed retries.
    • delay

      private final long delay
      Retry interval between subsequent retries in milliseconds.
    • RETRY_MESSAGE_TEMPLATE

      private static final String RETRY_MESSAGE_TEMPLATE
      See Also:
  • Constructor Details

    • NvdApiRetryStrategy

      public NvdApiRetryStrategy(int maxRetries, long delay)
      Constructs a new NVD API retry strategy.
      Parameters:
      maxRetries - the maximum number of retry attempts
      delay - the delay in milliseconds between retries
  • Method Details

    • retryRequest

      public boolean retryRequest(@Nonnull org.apache.hc.core5.http.HttpRequest request, @Nonnull IOException exception, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
      Specified by:
      retryRequest in interface org.apache.hc.client5.http.HttpRequestRetryStrategy
      Overrides:
      retryRequest in class org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
    • retryRequest

      public boolean retryRequest(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
      Specified by:
      retryRequest in interface org.apache.hc.client5.http.HttpRequestRetryStrategy
      Overrides:
      retryRequest in class org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
    • logRetryState

      private void logRetryState(@Nonnull org.apache.hc.core5.http.HttpRequest request, @Nonnull IOException exception, int execCount)
    • getRetryInterval

      public org.apache.hc.core5.util.TimeValue getRetryInterval(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
      Specified by:
      getRetryInterval in interface org.apache.hc.client5.http.HttpRequestRetryStrategy
      Overrides:
      getRetryInterval in class org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
    • toOrdinal

      public static String toOrdinal(int number)
      Converts a number to an ordinal string.
      Parameters:
      number - the number to convert
      Returns:
      the ordinal string