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

Wiremock server becomes unresponsive when ContextCache is evicted by removeEldestEntry() #1942

Open
rszabolcs opened this issue Sep 18, 2023 · 4 comments
Labels

Comments

@rszabolcs
Copy link

rszabolcs commented Sep 18, 2023

Remarks

Initially I raised this issue here and here. Then I was suggested to report it here instead.

Description

We have a project in Spring Boot (version 2.7.14) that is extensively tested and we noticed that at some point some of our tests start failing without apparent reason.

I could boil down the issue into a sample project as seen here. Run the whole test suite and the last service test will fail but it shouldn't.

After digging into the details you can find that after DefaultContextCache.this.remove(eldest.getKey(), HierarchyMode.CURRENT_LEVEL) is called within removeEldestEntry() in LruCache then something happens that makes Wiremock server to behave instable.

If we replace this logic to not remove an element but to reset the whole cache then all tests will be green. This workaround
is found here.

Reproduction steps

Run the whole test suite here and the last service test will fail but it shouldn't.

@marcingrzejszczak
Copy link
Contributor

Are you willing to file a PR to Spring Cloud Contract (3.1.x I guess) with a failing text and a fix (I see that you have a workaround)?

@rszabolcs
Copy link
Author

Hello, thanks for checking it!
I'm not sure this workaround of mine would be a proper solution. I don't fully understand why the workaround works exactly. Somehow WireMock gets screwed when ContextCache is evicted to make it possible to add an element again. When we reset it instead of removing an element, apparently it's working fine. But I wouldn't know why.

@marcingrzejszczak
Copy link
Contributor

Ok, so are you able to create a test that will break with the current implementation?

@rszabolcs
Copy link
Author

Exactly. Run the whole test suite of main branch of this repo. The last service test will fail but it shouldn't.

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

3 participants