Skip to content

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

Merged
merged 10 commits into from
Jun 9, 2018

Conversation

markcowl
Copy link
Member

@markcowl markcowl commented May 17, 2018

Description

Checklist

@markcowl
Copy link
Member Author

@cormacpayne
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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;

Copy link
Member

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);
Copy link
Member

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

Copy link
Member

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


Copy link
Member

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?

Copy link
Member Author

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))
Copy link
Member

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

@cormacpayne
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants