Skip to content

Commit 22c3ead

Browse files
committed
revert SuppressThrowing changes
1 parent 85714df commit 22c3ead

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

dotnet/test/common/Environment/RemoteSeleniumServer.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ public async Task StartAsync()
6666

6767
while (!isRunning && DateTime.Now < timeout)
6868
{
69-
var statusTask = httpClient.GetAsync("http://localhost:6000/wd/hub/status");
70-
await ((Task)statusTask).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
69+
try
70+
{
71+
using var response = await httpClient.GetAsync("http://localhost:6000/wd/hub/status");
7172

72-
if (statusTask.IsCompletedSuccessfully && statusTask.Result.StatusCode == HttpStatusCode.OK)
73+
if (response.StatusCode == HttpStatusCode.OK)
74+
{
75+
isRunning = true;
76+
}
77+
}
78+
catch (Exception ex) when (ex is HttpRequestException || ex is TimeoutException)
7379
{
74-
isRunning = true;
7580
}
7681
}
77-
78-
if (!isRunning)
79-
{
80-
throw new TimeoutException("Could not start the remote selenium server in 30 seconds");
81-
}
8282
}
8383
}
8484

@@ -88,8 +88,13 @@ public async Task StopAsync()
8888
{
8989
using (var httpClient = new HttpClient())
9090
{
91-
await ((Task)httpClient.GetAsync("http://localhost:6000/selenium-server/driver?cmd=shutDownSeleniumServer"))
92-
.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
91+
try
92+
{
93+
using var response = await httpClient.GetAsync("http://localhost:6000/selenium-server/driver?cmd=shutDownSeleniumServer");
94+
}
95+
catch (Exception ex) when (ex is HttpRequestException || ex is TimeoutException)
96+
{
97+
}
9398
}
9499

95100
webserverProcess.WaitForExit(10000);

dotnet/test/common/Environment/TestWebServer.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,17 @@ public async Task StopAsync()
181181
{
182182
using (var httpClient = new HttpClient())
183183
{
184-
await ((Task)httpClient.GetAsync(EnvironmentManager.Instance.UrlBuilder.LocalWhereIs("quitquitquit")))
185-
.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
184+
try
185+
{
186+
using (await httpClient.GetAsync(EnvironmentManager.Instance.UrlBuilder.LocalWhereIs("quitquitquit")))
187+
{
188+
189+
}
190+
}
191+
catch (HttpRequestException)
192+
{
193+
194+
}
186195
}
187196

188197
try

0 commit comments

Comments
 (0)