Skip to content
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

Fixing Async Deadlock #1486

Merged
merged 1 commit into from
Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Octokit/Clients/Enterprise/EnterpriseProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task<EnterpriseProbeResult> Probe(Uri enterpriseBaseUrl)
IResponse response;
try
{
response = await httpClient.Send(request);
response = await httpClient.Send(request).ConfigureAwait(false);
}
catch (ApiException ex)
{
Expand Down
8 changes: 4 additions & 4 deletions Octokit/Clients/MigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<Migration> Start(string org, StartMigrationRequest migration)

var endpoint = ApiUrls.EnterpriseMigrations(org);

return await ApiConnection.Post<Migration>(endpoint, migration, AcceptHeaders.MigrationsApiPreview);
return await ApiConnection.Post<Migration>(endpoint, migration, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -53,7 +53,7 @@ public async Task<List<Migration>> GetAll(string org)

var endpoint = ApiUrls.EnterpriseMigrations(org);

return await ApiConnection.Get<List<Migration>>(endpoint, null, AcceptHeaders.MigrationsApiPreview);
return await ApiConnection.Get<List<Migration>>(endpoint, null, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -71,7 +71,7 @@ public async Task<Migration> Get(string org, int id)

var endpoint = ApiUrls.EnterpriseMigrationById(org, id);

return await ApiConnection.Get<Migration>(endpoint, null, AcceptHeaders.MigrationsApiPreview);
return await ApiConnection.Get<Migration>(endpoint, null, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -88,7 +88,7 @@ public async Task<byte[]> GetArchive(string org, int id)
Ensure.ArgumentNotNullOrEmptyString(org, "org");

var endpoint = ApiUrls.EnterpriseMigrationArchive(org, id);
var response = await Connection.Get<byte[]>(endpoint, null, AcceptHeaders.MigrationsApiPreview);
var response = await Connection.Get<byte[]>(endpoint, null, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false);

return response.Body;
}
Expand Down
6 changes: 2 additions & 4 deletions Octokit/Clients/PullRequestsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ public async Task<PullRequestMerge> Merge(string owner, string name, int number,
try
{
var endpoint = ApiUrls.MergePullRequest(owner, name, number);
return await ApiConnection.Put<PullRequestMerge>(endpoint, mergePullRequest, null,
AcceptHeaders.SquashCommitPreview).ConfigureAwait(false);
return await ApiConnection.Put<PullRequestMerge>(endpoint, mergePullRequest, null, AcceptHeaders.SquashCommitPreview).ConfigureAwait(false);
}
catch (ApiException ex)
{
Expand Down Expand Up @@ -292,8 +291,7 @@ public async Task<PullRequestMerge> Merge(long repositoryId, int number, MergePu
try
{
var endpoint = ApiUrls.MergePullRequest(repositoryId, number);
return await ApiConnection.Put<PullRequestMerge>(endpoint, mergePullRequest, null,
AcceptHeaders.SquashCommitPreview).ConfigureAwait(false);
return await ApiConnection.Put<PullRequestMerge>(endpoint, mergePullRequest, null, AcceptHeaders.SquashCommitPreview).ConfigureAwait(false);
}
catch (ApiException ex)
{
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Clients/RepoCollaboratorsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public async Task<bool> Add(string owner, string name, string user, Collaborator

try
{
var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(owner, name, user), permission);
var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(owner, name, user), permission).ConfigureAwait(false);
return response.HttpResponse.IsTrue();
}
catch
Expand Down Expand Up @@ -217,7 +217,7 @@ public async Task<bool> Add(long repositoryId, string user, CollaboratorRequest

try
{
var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(repositoryId, user), permission);
var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(repositoryId, user), permission).ConfigureAwait(false);
return response.HttpResponse.IsTrue();
}
catch
Expand Down
24 changes: 8 additions & 16 deletions Octokit/Clients/StatisticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public async Task<CommitActivity> GetCommitActivity(string owner, string name, C
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

var activity = await ApiConnection.GetQueuedOperation<WeeklyCommitActivity>(
ApiUrls.StatsCommitActivity(owner, name), cancellationToken).ConfigureAwait(false);
var activity = await ApiConnection.GetQueuedOperation<WeeklyCommitActivity>(ApiUrls.StatsCommitActivity(owner, name), cancellationToken).ConfigureAwait(false);
return new CommitActivity(activity);
}

Expand All @@ -112,8 +111,7 @@ public async Task<CommitActivity> GetCommitActivity(string owner, string name, C
/// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
public async Task<CommitActivity> GetCommitActivity(long repositoryId, CancellationToken cancellationToken)
{
var activity = await ApiConnection.GetQueuedOperation<WeeklyCommitActivity>(
ApiUrls.StatsCommitActivity(repositoryId), cancellationToken).ConfigureAwait(false);
var activity = await ApiConnection.GetQueuedOperation<WeeklyCommitActivity>(ApiUrls.StatsCommitActivity(repositoryId), cancellationToken).ConfigureAwait(false);
return new CommitActivity(activity);
}

Expand Down Expand Up @@ -150,8 +148,7 @@ public async Task<CodeFrequency> GetCodeFrequency(string owner, string name, Can
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

var rawFrequencies = await ApiConnection.GetQueuedOperation<long[]>(
ApiUrls.StatsCodeFrequency(owner, name), cancellationToken).ConfigureAwait(false);
var rawFrequencies = await ApiConnection.GetQueuedOperation<long[]>(ApiUrls.StatsCodeFrequency(owner, name), cancellationToken).ConfigureAwait(false);
return new CodeFrequency(rawFrequencies);
}

Expand All @@ -162,8 +159,7 @@ public async Task<CodeFrequency> GetCodeFrequency(string owner, string name, Can
/// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
public async Task<CodeFrequency> GetCodeFrequency(long repositoryId, CancellationToken cancellationToken)
{
var rawFrequencies = await ApiConnection.GetQueuedOperation<long[]>(
ApiUrls.StatsCodeFrequency(repositoryId), cancellationToken).ConfigureAwait(false);
var rawFrequencies = await ApiConnection.GetQueuedOperation<long[]>(ApiUrls.StatsCodeFrequency(repositoryId), cancellationToken).ConfigureAwait(false);
return new CodeFrequency(rawFrequencies);
}

Expand Down Expand Up @@ -200,8 +196,7 @@ public async Task<Participation> GetParticipation(string owner, string name, Can
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

var result = await ApiConnection.GetQueuedOperation<Participation>(
ApiUrls.StatsParticipation(owner, name), cancellationToken).ConfigureAwait(false);
var result = await ApiConnection.GetQueuedOperation<Participation>(ApiUrls.StatsParticipation(owner, name), cancellationToken).ConfigureAwait(false);
return result.FirstOrDefault();
}

Expand All @@ -212,8 +207,7 @@ public async Task<Participation> GetParticipation(string owner, string name, Can
/// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
public async Task<Participation> GetParticipation(long repositoryId, CancellationToken cancellationToken)
{
var result = await ApiConnection.GetQueuedOperation<Participation>(
ApiUrls.StatsParticipation(repositoryId), cancellationToken).ConfigureAwait(false);
var result = await ApiConnection.GetQueuedOperation<Participation>(ApiUrls.StatsParticipation(repositoryId), cancellationToken).ConfigureAwait(false);
return result.FirstOrDefault();
}

Expand Down Expand Up @@ -250,8 +244,7 @@ public async Task<PunchCard> GetPunchCard(string owner, string name, Cancellatio
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

var punchCardData = await ApiConnection.GetQueuedOperation<int[]>(
ApiUrls.StatsPunchCard(owner, name), cancellationToken).ConfigureAwait(false);
var punchCardData = await ApiConnection.GetQueuedOperation<int[]>(ApiUrls.StatsPunchCard(owner, name), cancellationToken).ConfigureAwait(false);
return new PunchCard(punchCardData);
}

Expand All @@ -262,8 +255,7 @@ public async Task<PunchCard> GetPunchCard(string owner, string name, Cancellatio
/// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
public async Task<PunchCard> GetPunchCard(long repositoryId, CancellationToken cancellationToken)
{
var punchCardData = await ApiConnection.GetQueuedOperation<int[]>(
ApiUrls.StatsPunchCard(repositoryId), cancellationToken).ConfigureAwait(false);
var punchCardData = await ApiConnection.GetQueuedOperation<int[]>(ApiUrls.StatsPunchCard(repositoryId), cancellationToken).ConfigureAwait(false);
return new PunchCard(punchCardData);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Http/HttpClientAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected virtual void Dispose(bool disposing)
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// Clone the request/content incase we get a redirect
var clonedRequest = await CloneHttpRequestMessageAsync(request);
var clonedRequest = await CloneHttpRequestMessageAsync(request).ConfigureAwait(false);

// Send initial response
var response = await _http.SendAsync(request, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
Expand Down