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

fix(server): MockHttpServer.StopAsync disposes the host before it has a chance to actually stop. #88

Merged
merged 1 commit into from
Nov 18, 2023

Conversation

skwasjer
Copy link
Owner

Fixes some async issues with starting and stopping the MockHttpServer:

  • The MockHttpServer.StopAsync method was not properly awaiting the inner host.StopAsync and disposing the host in the finally block.
try
{
    return host.StopAsync(cancellationToken);  // Returning a task without awaiting.
}
finally
{
    host.Dispose(); // But then disposing.
}
  • lock(object) { } is not supported in async context so replaced it with a SemaphoreSlim.
  • The StartAsync/StopAsync methods no longer throw when called multiple times, and instead just return without doing anything.

…pAsync() was not being awaited. Additionally, lock(object) is not supported in async context so replaced it with SemaphoreSlim. The StartAsync/StopAsync methods now also no longer throw when called multiple times.
@skwasjer skwasjer enabled auto-merge (squash) November 18, 2023 20:58
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@skwasjer skwasjer merged commit 3639e12 into main Nov 18, 2023
13 checks passed
@skwasjer skwasjer deleted the fix/server_locking branch November 18, 2023 21:03
@skwasjer skwasjer added the bug Something isn't working label Dec 24, 2023
@skwasjer skwasjer changed the title fix(server): MockHttpServer.StopAsync disposes the host before it has a change to actually stop. fix(server): MockHttpServer.StopAsync disposes the host before it has a chance to actually stop. Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant