-
Notifications
You must be signed in to change notification settings - Fork 30
- fixes retry/redirect options customization #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
baywet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for you contribution @Asky-GH ! Some minor comments from my side. Also, can you make sure you sign the CLA please?
|
@MIchaelMainer or @zengin can you take a look as well please? |
| final RedirectOptions redirectOptions = | ||
| request.getMaxRedirects() == DEFAULT_MAX_REDIRECTS && request.getShouldRedirect().equals(DEFAULT_SHOULD_REDIRECT) | ||
| ? null | ||
| : new RedirectOptions(request.getMaxRedirects(), request.getShouldRedirect()); | ||
| final RetryOptions retryOptions = | ||
| request.getMaxRetries() == DEFAULT_MAX_RETRIES && request.getDelay() == DEFAULT_DELAY && request.getShouldRetry().equals(DEFAULT_SHOULD_RETRY) | ||
| ? null | ||
| : new RetryOptions(request.getShouldRetry(), request.getMaxRetries(), request.getDelay()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required for giving the flexibility to custom handler implementations?
In the default implementation of RetryHandler and RedirectHandler, the constructors end up calling the default option constructors if they are null. Default constructors of options are already using these default values. This piece of code seems equivalent to:
| final RedirectOptions redirectOptions = | |
| request.getMaxRedirects() == DEFAULT_MAX_REDIRECTS && request.getShouldRedirect().equals(DEFAULT_SHOULD_REDIRECT) | |
| ? null | |
| : new RedirectOptions(request.getMaxRedirects(), request.getShouldRedirect()); | |
| final RetryOptions retryOptions = | |
| request.getMaxRetries() == DEFAULT_MAX_RETRIES && request.getDelay() == DEFAULT_DELAY && request.getShouldRetry().equals(DEFAULT_SHOULD_RETRY) | |
| ? null | |
| : new RetryOptions(request.getShouldRetry(), request.getMaxRetries(), request.getDelay()); | |
| final RedirectOptions redirectOptions = new RedirectOptions(request.getMaxRedirects(), request.getShouldRedirect()); | |
| final RetryOptions retryOptions = new RetryOptions(request.getShouldRetry(), request.getMaxRetries(), request.getDelay()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @zengin
The changes you are suggesting work effectively the same as the current code of the library. If you take a look at CoreHttpProvider's line 245:
if(redirectOptions != null) {
corehttpRequestBuilder = corehttpRequestBuilder.tag(RedirectOptions.class, redirectOptions);
}
if(retryOptions != null) {
corehttpRequestBuilder = corehttpRequestBuilder.tag(RetryOptions.class, retryOptions);
}RedirectHandler's line 133:
RedirectOptions redirectOptions = request.tag(RedirectOptions.class);
redirectOptions = redirectOptions != null ? redirectOptions : this.mRedirectOptions;and RetryHandler's line 179:
RetryOptions retryOption = request.tag(RetryOptions.class);
retryOption = retryOption != null ? retryOption : mRetryOption;you can see that mRedirectOptions and mRetryOption will never be used. Thus it is impossible to customize them so to speak globaly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying.
Fixes #181
Changes proposed in this pull request