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

Inconsistent result with overlapping (duplicate) request #856

Closed
Morshed11218 opened this issue Dec 3, 2022 · 2 comments
Closed

Inconsistent result with overlapping (duplicate) request #856

Morshed11218 opened this issue Dec 3, 2022 · 2 comments
Assignees
Labels

Comments

@Morshed11218
Copy link

Morshed11218 commented Dec 3, 2022

Hi,
I'm experiencing inconsistent result when it comes to overlapping (duplicate) request. In the WireMock documentation, it states that for a overlapping request, the most recent mock will be returned but I'm not seeing that behavior. What I'm seeing is that the response will sometimes be the first mock or the most recent mock.

Here is the sample code:

            for(var i = 0; i < 20; i++)
            {
                var server = WireMockServer.Start();

                server
                  .Given(
                    Request.Create().WithPath("/some/thing").UsingGet()
                  )
                  .RespondWith(
                    Response.Create()
                      .WithStatusCode(200)
                      .WithHeader("Content-Type", "text/plain")
                      .WithBody("Hello world!")
                  );

                server
                  .Given(
                    Request.Create().WithPath("/some/thing").UsingGet()
                  )
                  .RespondWith(
                    Response.Create()
                      .WithStatusCode(200)
                      .WithHeader("Content-Type", "text/plain")
                      .WithBody("Hello world duplicate!")
                  );

                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync($"{server.Url}/some/thing");
                    var content = await response.Content.ReadAsStringAsync();
                    Console.WriteLine($"counter {i} value:{content}");
                }

                server.Reset();
                server.Dispose();
                server.Stop();
            }

I'm expecting 'Hello world duplicate!' all the time but I sometime get 'Hello world!'

Result:

counter 0 value:Hello world!
counter 1 value:Hello world duplicate!
counter 2 value:Hello world!
counter 3 value:Hello world duplicate!
counter 4 value:Hello world!
counter 5 value:Hello world!
counter 6 value:Hello world duplicate!
counter 7 value:Hello world!
counter 8 value:Hello world duplicate!
counter 9 value:Hello world!
counter 10 value:Hello world!
counter 11 value:Hello world!
counter 12 value:Hello world duplicate!
counter 13 value:Hello world!
counter 14 value:Hello world duplicate!
counter 15 value:Hello world duplicate!
counter 16 value:Hello world duplicate!
counter 17 value:Hello world duplicate!
counter 18 value:Hello world!
counter 19 value:Hello world!

@StefH StefH self-assigned this Dec 3, 2022
@StefH StefH added the bug label Dec 4, 2022
@StefH
Copy link
Collaborator

StefH commented Dec 4, 2022

@Morshed11218
This is indeed wrong. I did fix it.

Can you test a preview version "1.5.12-ci-16783" ?

(https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

@Morshed11218
Copy link
Author

@StefH
It's working with build "1.5.12-ci-16783". Thanks for the quick fix.

@StefH StefH closed this as completed Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants