kwin commented on code in PR #326:
URL: https://github.com/apache/maven-resolver/pull/326#discussion_r1314790551


##########
maven-resolver-api/src/main/java/org/eclipse/aether/ConfigurationProperties.java:
##########
@@ -144,6 +144,41 @@ public final class ConfigurationProperties {
      */
     public static final int DEFAULT_HTTP_RETRY_HANDLER_COUNT = 3;
 
+    /**
+     * The retry interval of request to a remote server should be waited in 
case of "too many requests"
+     * (HTTP codes 429 and 503). Accepts long as milliseconds.
+     *
+     * @see #DEFAULT_HTTP_RETRY_HANDLER_INTERVAL
+     * @since 1.9.16
+     */
+    public static final String HTTP_RETRY_HANDLER_INTERVAL = PREFIX_CONNECTOR 
+ "http.retryHandler.interval";

Review Comment:
   Header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After 
should be considered and used preferably 



##########
maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java:
##########
@@ -704,4 +733,37 @@ public void writeTo(OutputStream os) throws IOException {
             }
         }
     }
+
+    private static class ResolverServiceUnavailableRetryStrategy implements 
ServiceUnavailableRetryStrategy {
+        private final int retryCount;
+
+        private final long retryInterval;
+
+        private final Set<Integer> serviceUnavailableHttpCodes;
+
+        private ResolverServiceUnavailableRetryStrategy(
+                int retryCount, long retryInterval, Set<Integer> 
serviceUnavailableHttpCodes) {
+            if (retryCount < 0) {
+                throw new IllegalArgumentException("retryCount must be >= 0");
+            }
+            if (retryInterval < 0L) {
+                throw new IllegalArgumentException("retryInterval must be >= 
0");
+            }
+            this.retryCount = retryCount;
+            this.retryInterval = retryInterval;
+            this.serviceUnavailableHttpCodes = 
requireNonNull(serviceUnavailableHttpCodes);
+        }
+
+        @Override
+        public boolean retryRequest(HttpResponse response, int executionCount, 
HttpContext context) {
+            return executionCount <= retryCount
+                    && (serviceUnavailableHttpCodes.contains(
+                            response.getStatusLine().getStatusCode()));
+        }
+
+        @Override
+        public long getRetryInterval() {
+            return retryInterval;

Review Comment:
   By default an exponential backoff usually makes sense



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to