Skip to content

Commit

Permalink
fix: add 429 errors to retry (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylong authored Nov 24, 2023
1 parent 69ab87c commit a877203
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class NvdApiRetryStrategy extends DefaultHttpRequestRetryStrategy {

public NvdApiRetryStrategy(int maxRetries, long delay) {
super(maxRetries, TimeValue.of(delay, TimeUnit.MILLISECONDS), new ArrayList<Class<? extends IOException>>(),
Arrays.asList(503));
Arrays.asList(429, 503));
this.maxRetries = maxRetries;
this.delay = delay;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public class NvdCveClient implements PagedDataSource<DefCveItem> {
* @param endpoint the endpoint for the NVD CVE API; if null the default endpoint is used
* @param threadCount the number of threads to use when calling the NVD API.
* @param maxPageCount the maximum number of pages to retrieve from the NVD API.
* @param maxRetryCount the maximum number of retries for 503 status code responses.
* @param maxRetryCount the maximum number of retries for 503 and 429 status code responses.
*/
NvdCveClient(String apiKey, String endpoint, int threadCount, int maxPageCount, int maxRetryCount) {
this(apiKey, endpoint, apiKey == null ? 6500 : 600, threadCount, maxPageCount, maxRetryCount);
Expand All @@ -157,7 +157,7 @@ public class NvdCveClient implements PagedDataSource<DefCveItem> {
* @param delay the delay in milliseconds between API calls on a single thread.
* @param threadCount the number of threads to use when calling the NVD API.
* @param maxPageCount the maximum number of pages to retrieve from the NVD API.
* @param maxRetryCount the maximum number of retries for 503 status code responses.
* @param maxRetryCount the maximum number of retries for 503 and 429 status code responses.
*/
NvdCveClient(String apiKey, String endpoint, long delay, int threadCount, int maxPageCount, int maxRetryCount) {
this.apiKey = apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public final class NvdCveClientBuilder {
*/
private long delay;
/**
* The maximum number of retries for 503 responses from the NVD.
* The maximum number of retries for 503 and 429 responses from the NVD.
*/
private int maxRetryCount = 10;
/**
Expand Down Expand Up @@ -127,9 +127,9 @@ public NvdCveClientBuilder withDelay(long milliseconds) {
}

/**
* Set the maximum number of retries for 503 responses from the NVD; default is 10.
* Set the maximum number of retries for 503 and 429 responses from the NVD; default is 10.
*
* @param maxRetryCount the maximum number of retries for 503 responses from the NVD.
* @param maxRetryCount the maximum number of retries for 503 and 429 responses from the NVD.
* @return the builder
*/
public NvdCveClientBuilder withMaxRetryCount(int maxRetryCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class AbstractNvdCommand extends AbstractJsonCommand {
"--delay"}, description = "The delay in milliseconds between API calls to the NVD - important if pulling a larger data set without an API Key")
private int delay;
@CommandLine.Option(names = {
"--maxRetry"}, description = "The maximum number of retry attempts on 503 errors from the NVD API")
"--maxRetry"}, description = "The maximum number of retry attempts on 503 and 429 errors from the NVD API")
private int maxRetry;
@CommandLine.Option(names = {
"--pageCount"}, description = "The number of `pages` of data to retrieve from the NVD if more then a single page is returned")
Expand Down

0 comments on commit a877203

Please sign in to comment.