Skip to content

Conversation

@Asky-GH
Copy link
Contributor

@Asky-GH Asky-GH commented Apr 7, 2021

Fixes #181

Changes proposed in this pull request

  • Change conditions used to evaluate Request level middleware options

@ghost
Copy link

ghost commented Apr 7, 2021

CLA assistant check
All CLA requirements met.

Copy link
Member

@baywet baywet left a 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?

@Asky-GH Asky-GH marked this pull request as ready for review April 8, 2021 18:53
baywet
baywet previously approved these changes Apr 8, 2021
@baywet
Copy link
Member

baywet commented Apr 8, 2021

@MIchaelMainer or @zengin can you take a look as well please?

Comment on lines +245 to +252
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());
Copy link
Contributor

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:

Suggested change
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());

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying.

@baywet baywet added this to the 2.0.1 milestone Apr 12, 2021
zengin
zengin previously approved these changes Apr 12, 2021
@baywet baywet mentioned this pull request Apr 13, 2021
@baywet baywet dismissed stale reviews from zengin and themself via ba0d5fd April 14, 2021 14:37
@baywet
Copy link
Member

baywet commented Apr 14, 2021

@Asky-GH Thanks for your contribution, I just added more unit testing to your PR to make sure we know if we break things again in the future.
@zengin thanks for the review!

@baywet baywet enabled auto-merge April 14, 2021 14:39
@baywet baywet merged commit ff8c1f3 into microsoftgraph:dev Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to configure the Microsoft Graph SDK client with custom 'maxRetries' and 'delay' options

3 participants