Skip to content

Commit

Permalink
Revert "allow null CancellationToken"
Browse files Browse the repository at this point in the history
The null errors were from httpClient, not the cancellation token. They
were happening because HgServiceTests mocks IHttpClientFactory,
returning null when code tries to access HttpClient. We'll need to mock
IHttpClientFactory in a slightly more detailed way.
  • Loading branch information
rmunn committed May 9, 2024
1 parent ffb086a commit b48802f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions backend/LexBoxApi/Services/HgService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,11 @@ public async Task InvalidateDirCache(string code)
return int.TryParse(str, out int result) ? result : null;
}

private async Task<HttpContent> ExecuteHgCommandServerCommand(string code, string command, CancellationToken? token)
private async Task<HttpContent> ExecuteHgCommandServerCommand(string code, string command, CancellationToken token)
{
var httpClient = _hgClient.Value;
var baseUri = _options.Value.HgCommandServer;
var response = token == null
? await httpClient.GetAsync($"{baseUri}{code}/{command}", HttpCompletionOption.ResponseHeadersRead)
: await httpClient.GetAsync($"{baseUri}{code}/{command}", HttpCompletionOption.ResponseHeadersRead, token.Value);
var response = await httpClient.GetAsync($"{baseUri}{code}/{command}", HttpCompletionOption.ResponseHeadersRead, token);
response.EnsureSuccessStatusCode();
return response.Content;
}
Expand Down

0 comments on commit b48802f

Please sign in to comment.