Skip to content

Commit cf55c30

Browse files
Use async await
1 parent 844e6f0 commit cf55c30

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Infrastructure/src/TriageBuildFailures/TeamCity/TeamCityClient.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public TeamCityClientWrapper(TeamCityConfig config, IReporter reporter)
3030
{
3131
Config = config;
3232
_reporter = reporter;
33-
33+
3434
if (TeamCityBuild.BuildNames == null)
3535
{
3636
TeamCityBuild.BuildNames = GetBuildTypes();
3737
}
3838
}
39-
39+
4040
public async Task<string> GetTestFailureText(ICITestOccurrence test)
4141
{
4242
var url = $"failedTestText.html?buildId={test.BuildId}&testId={test.TestId}";
@@ -55,7 +55,7 @@ public async Task<string> GetTestFailureText(ICITestOccurrence test)
5555
{
5656
if (line.StartsWith("======= Failed test run", StringComparison.OrdinalIgnoreCase))
5757
{
58-
if(firstEqualLineSeen)
58+
if (firstEqualLineSeen)
5959
{
6060
break;
6161
}
@@ -77,7 +77,7 @@ public async Task<string> GetTestFailureText(ICITestOccurrence test)
7777
public async Task<IEnumerable<ICITestOccurrence>> GetTests(ICIBuild build, BuildStatus? buildStatus = null)
7878
{
7979
var locator = $"build:(id:{build.Id})";
80-
if(buildStatus != null)
80+
if (buildStatus != null)
8181
{
8282
locator += $",status:{Enum.GetName(typeof(BuildStatus), buildStatus)}";
8383
}
@@ -162,7 +162,7 @@ public async Task<IEnumerable<ICIBuild>> GetBuilds(string locator)
162162
}
163163
}
164164

165-
private Task<Stream> MakeTeamCityRequest(HttpMethod method, string url, string body = null, TimeSpan? timeout = null)
165+
private async Task<Stream> MakeTeamCityRequest(HttpMethod method, string url, string body = null, TimeSpan? timeout = null)
166166
{
167167
var requestUri = $"http://{Config.Server}/{url}";
168168

@@ -172,7 +172,7 @@ private Task<Stream> MakeTeamCityRequest(HttpMethod method, string url, string b
172172
var request = new HttpRequestMessage(method, requestUri);
173173
request.Headers.Authorization = new AuthenticationHeaderValue("Basic", authEncoded);
174174

175-
if(body != null)
175+
if (body != null)
176176
{
177177
request.Content = new StringContent(body);
178178
}
@@ -184,15 +184,15 @@ private Task<Stream> MakeTeamCityRequest(HttpMethod method, string url, string b
184184
client.Timeout = timeout.Value;
185185
}
186186

187-
var response = client.SendAsync(request).Result;
187+
var response = await client.SendAsync(request);
188188

189189
if (response.StatusCode == HttpStatusCode.OK)
190190
{
191-
return response.Content.ReadAsStreamAsync();
191+
return await response.Content.ReadAsStreamAsync();
192192
}
193193
else
194194
{
195-
var content = response.Content.ReadAsStringAsync().Result;
195+
var content = await response.Content.ReadAsStringAsync();
196196
_reporter.Error($"HTTP error: {response.StatusCode}");
197197
_reporter.Error($"Content: {content}");
198198
throw new HttpRequestException(response.StatusCode.ToString());

0 commit comments

Comments
 (0)