-
Notifications
You must be signed in to change notification settings - Fork 4k
Handle TaskCanceledExceptions for all clients #6245
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
Potential fix for #6165 |
@@ -56,11 +57,8 @@ public ClientFactory() | |||
} | |||
|
|||
var creds = AzureSession.Instance.AuthenticationFactory.GetServiceClientCredentials(context, endpoint); | |||
var newHandlers = GetCustomHandlers(); | |||
TClient client = (newHandlers == null || newHandlers.Length == 0) |
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.
@markcowl why was this check for custom handlers removed?
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.
Discussed offline - because we move custom handler addition into the CreateCustomClient implementation later in this PR
|
||
foreach (IClientAction action in GetActions()) | ||
{ | ||
action.Apply<TClient>(client, profile, endpoint); | ||
} | ||
|
||
return client; | ||
|
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.
@markcowl nit: remove new line
} | ||
catch (TaskCanceledException) when (tries++ < MaxTries) | ||
{ | ||
Thread.Sleep(WaitInterval); |
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.
@markcowl should we be using TestUtilities.Wait(WaitInterval)
here?
autoRestHandler.MaxTries = 0; | ||
task = autorestClient.ResourceGroups.ListWithHttpMessagesAsync(); | ||
Assert.Throws<TaskCanceledException>(() => task.ConfigureAwait(false).GetAwaiter().GetResult()); | ||
|
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.
@markcowl nit: remove these last few new lines
task = autorestClient.ResourceGroups.ListWithHttpMessagesAsync(); | ||
Assert.Throws<TaskCanceledException>(() => task.ConfigureAwait(false).GetAwaiter().GetResult()); | ||
|
||
|
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.
@markcowl do we need an assert for a successful retry of a list call and validating that content was returned from the call?
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 think we have that covered elsewhere
void SleepIfRunningLive(TimeSpan timeSpan) | ||
{ | ||
var testModeSetting = Environment.GetEnvironmentVariable(TestModeVariableKey); | ||
if (string.IsNullOrWhiteSpace(testModeSetting) || !string.Equals(TestModeVariableValue, testModeSetting, StringComparison.OrdinalIgnoreCase)) |
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.
@markcowl this should check for Record
and Live
Description
Checklist
CONTRIBUTING.md
platyPS
module