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
FieldsModifier and TypeFieldDescriptionprivate final longRetry interval between subsequent retries in milliseconds.private static final org.slf4j.LoggerReference to the logger.private final intMaximum number of allowed retries.private static final StringFields inherited from class org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
INSTANCE -
Constructor Summary
ConstructorsConstructorDescriptionNvdApiRetryStrategy(int maxRetries, long delay) Constructs a new NVD API retry strategy. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.core5.util.TimeValuegetRetryInterval(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) private voidlogRetryState(org.apache.hc.core5.http.HttpRequest request, IOException exception, int execCount) booleanretryRequest(org.apache.hc.core5.http.HttpRequest request, IOException exception, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) booleanretryRequest(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) static StringtoOrdinal(int number) Converts a number to an ordinal string.Methods inherited from class org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
handleAsIdempotentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hc.client5.http.HttpRequestRetryStrategy
getRetryInterval
-
Field Details
-
LOG
private static final org.slf4j.Logger LOGReference to the logger. -
maxRetries
private final int maxRetriesMaximum number of allowed retries. -
delay
private final long delayRetry interval between subsequent retries in milliseconds. -
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 attemptsdelay- 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:
retryRequestin interfaceorg.apache.hc.client5.http.HttpRequestRetryStrategy- Overrides:
retryRequestin classorg.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:
retryRequestin interfaceorg.apache.hc.client5.http.HttpRequestRetryStrategy- Overrides:
retryRequestin classorg.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:
getRetryIntervalin interfaceorg.apache.hc.client5.http.HttpRequestRetryStrategy- Overrides:
getRetryIntervalin classorg.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy
-
toOrdinal
Converts a number to an ordinal string.- Parameters:
number- the number to convert- Returns:
- the ordinal string
-