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

Times.once returns more than once #1826

Open
maestrokame opened this issue Dec 29, 2023 · 1 comment
Open

Times.once returns more than once #1826

maestrokame opened this issue Dec 29, 2023 · 1 comment

Comments

@maestrokame
Copy link

maestrokame commented Dec 29, 2023

Describe the issue
I mocked a request with Times.once() but the response is returned to more than one request.

What you are trying to do
I'm trying to mock an API that works like a queue. Multiple clients are polling that API waiting for any data to unconsume.
I'm trying to use Times.once() so that only to one of the clients can get the mocked response.

MockServer version
5.14.0

To Reproduce
A repository with minimal reproduceable. Please try a couple of times if it does not reproduce.
https://github.com/maestrokame/reproduce-mockserver-issue-with-once/tree/main

  1. How you are running MockServer (i.e maven plugin, docker, etc)
MockServerClient mockServer = ClientAndServer.startClientAndServer(3000);
  1. Code you used to create expectations
mockServer.when(request("/output/.*").withMethod("GET"), Times.once())
        .respond(response()
                .withStatusCode(200)
                .withBody("OK"));
  1. What error you saw
    No error. Just observed more than one API client getting the same response.

Expected behaviour
Return the response only to one of the clients

MockServer Log
log

@bonati-s
Copy link

Linked to #1834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants