-
Notifications
You must be signed in to change notification settings - Fork 814
Fix combining auth and retry #1414
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
91ac83e to
2bd39b2
Compare
| } | ||
|
|
||
| if (CommitedCallTask.IsCompletedSuccessfully() && CommitedCallTask.Result == call) | ||
| finally |
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.
I noticed we don't do any except handling on the top-level of the StartCall here. Is it worthwhile to do here or is the exception handling at the call sites sufficient?
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.
All logic that can throw should be inside a try/catch.
However, a global catch is a good idea for safety. Also, throwing on CTS cancellation and reusing HandleUnexpectedError simplifies the code.
Updated.
| // There is no response task if there was a preemptive cancel. | ||
| CompatibilityHelpers.Assert(call.CancellationToken.IsCancellationRequested, "Request should have been made if call is not preemptively cancelled."); | ||
| call.CancellationToken.ThrowIfCancellationRequested(); | ||
| httpResponse = await call.HttpResponseTask.ConfigureAwait(false); |
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.
| httpResponse = await call.HttpResponseTask.ConfigureAwait(false); | |
| httpResponse = await call!.HttpResponseTask.ConfigureAwait(false); |
call is guaranteed to be set here, correct? Annotation makes it a little easier to read since it's nullable.
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.
Yes, a call is always set at this point.
I think an annotation makes it less clear what is going on. Since this compiles, code analysis guarantes that it's not null here. An annotation would make me wonder why this could be null.
Fixes #1406
Adds a
TaskCompletionSource<HttpResponseMessage>so that the task to get the response is never null.Best reviewed with hide whitespace enabled.