Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Sep 2, 2023
1 parent f23aff7 commit cd93d6f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,21 @@ public final class ConfigurationProperties {
public static final int DEFAULT_HTTP_RETRY_HANDLER_COUNT = 3;

/**
* The initial retry interval of request to a remote server should be waited in case of "too many requests"
* (HTTP codes 429 and 503).
* 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";

/**
* The default initial retry interval to use if {@link #HTTP_RETRY_HANDLER_INTERVAL} isn't set.
* Default value 500 ms.
* The default retry interval to use if {@link #HTTP_RETRY_HANDLER_INTERVAL} isn't set.
* Default value 5000ms.
*
* @since 1.9.16
*/
public static final int DEFAULT_HTTP_RETRY_HANDLER_INTERVAL = 500;
public static final long DEFAULT_HTTP_RETRY_HANDLER_INTERVAL = 5000L;

/**
* The initial retry interval of request to a remote server should be waited in case of "too many requests"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,6 @@ private static class ResolverServiceUnavailableRetryStrategy implements ServiceU

private final Set<Integer> serviceUnavailableHttpCodes;

private final ThreadLocal<Long> retryIntervalHolder;

private ResolverServiceUnavailableRetryStrategy(
int retryCount, long retryInterval, Set<Integer> serviceUnavailableHttpCodes) {
if (retryCount < 0) {
Expand All @@ -754,28 +752,18 @@ private ResolverServiceUnavailableRetryStrategy(
this.retryCount = retryCount;
this.retryInterval = retryInterval;
this.serviceUnavailableHttpCodes = requireNonNull(serviceUnavailableHttpCodes);
this.retryIntervalHolder = new ThreadLocal<>();
}

@Override
public boolean retryRequest(HttpResponse response, int executionCount, HttpContext context) {
final boolean retry = executionCount <= retryCount
return executionCount <= retryCount
&& (serviceUnavailableHttpCodes.contains(
response.getStatusLine().getStatusCode()));
if (retry) {
retryIntervalHolder.set(executionCount * retryInterval);
}
return retry;
}

@Override
public long getRetryInterval() {
Long ri = retryIntervalHolder.get();
if (ri == null) {
return 0L;
}
retryIntervalHolder.remove();
return ri;
return retryInterval;
}
}
}
2 changes: 1 addition & 1 deletion src/site/markdown/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Option | Type | Description | Default Value | Supports Repo ID Suffix
`aether.connector.http.preemptiveAuth` | boolean | Should HTTP client use preemptive-authentication for all HTTP verbs (works only w/ BASIC). By default is disabled, as it is considered less secure. | `false` | yes
`aether.connector.http.preemptivePutAuth` | boolean | Should HTTP client use preemptive-authentication for HTTP PUTs only (works only w/ BASIC). By default is enabled (same as Wagon). | `true` | yes
`aether.connector.http.retryHandler.count` | int | The maximum number of times a request to a remote HTTP server should be retried in case of an error. | `3` | yes
`aether.connector.http.retryHandler.interval` | long | The initial retry interval if server responds with "too many requests", that is on subsequent requests multiplied with execution count (so with 1, 2, 3...). | `500` | yes
`aether.connector.http.retryHandler.interval` | long | The retry interval if server responds with "too many requests". | `5000` | yes
`aether.connector.http.retryHandler.name` | String | The name of retryHandler, supported values are "standard", that obeys RFC-2616, regarding idempotent methods, and "default" that considers requests w/o payload as idempotent. | `standard` | yes
`aether.connector.http.retryHandler.requestSentEnabled` | boolean | Set to `true` if it is acceptable to retry non-idempotent requests, that have been sent. | `false` | yes
`aether.connector.http.retryHandler.serviceUnavailable` | String | Comma separated list of HTTP codes that should be handled as "too many requests". | `"429,503"` | yes
Expand Down

0 comments on commit cd93d6f

Please sign in to comment.