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

Should KubernetesMockServer.reset() also reset DefaultMockServer.lastRequest* #6750

Open
gsmet opened this issue Dec 23, 2024 · 1 comment
Open
Labels
bug component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly

Comments

@gsmet
Copy link

gsmet commented Dec 23, 2024

Is your enhancement related to a problem? Please describe

In

public void reset() {
clearExpectations();
onStart();
unsupportedPatterns.clear();
if (this.dispatcher instanceof Resetable) {
((Resetable) this.dispatcher).reset();
}
}
, we don't reset the fields that are in DefaultMockServer and especially these three:
private final Map<ServerRequest, Queue<ServerResponse>> responses;
private final AtomicInteger lastRequestCount;
private final AtomicReference<RecordedRequest> lastRequest;
(but there might be others that make sense) .

It can be problematic when you actually try to check that no request have been sent with getLastRequest() after a reset() and some operations and you end up with the request sent pre-reset().

Describe the solution you'd like

Ideally, I would like DefaultMockServer to be reset when KubernetesMockServer is reset.

Describe alternatives you've considered

No response

Additional context

It looks like it comes out of the blue but I noticed it while doing some enhancements on sbomer and it got in the way.

@manusa
Copy link
Member

manusa commented Dec 24, 2024

Good catch, this does seem like a bug.

@manusa manusa added bug component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly
Projects
None yet
Development

No branches or pull requests

2 participants