-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ConcurrentModificationException when resetting the server #103
Comments
We've been using a fork of RESTMock with the proposed fix for a few weeks and it has stopped giving such error. We haven't seen any other related issues after that. Here's the fix: Sloy@1df65ea Do you think it would be a good idea if I submit a PR? |
Thaks for your input! Wouldn't simple Anyways, the PR would be very appreciated |
I don't think I've ever used I'll try to send a PR as soon as I have a bit of spare time. I could also submit some concurrency tests that I wrote to reproduce the issue (and for some reason didn't commit and deleted them 🤦♂). |
0.4.0 version should contain the abovementioned fix :) |
Hi! We've been using restmock for a while now, and we're often getting this Exception in many of our builds while running Android UI tests.
We suspect it's happening when we reset the matched requests before a new test, and at the same time there are is request from the previous test still running, because Android shares the process between tests.
More specifically, this happens when we invoke
RestMockServer.reset()
after a test, and at the same time the methodgetMatchedRequests()
is iterating thematchableCalls
list because some background thread made a request after the test already ended.We try to avoid this by using IdlingResources to make Espresso wait for our background tasks, but having almost 300 tests the probability of leaking some request is quite high.
I can think of an easy solution by replacing the
matchableCalls
type fromLinkedList
toCopyOnWriteArrayList
.This might cause the leaked request to not find a matched call and return an http 500 error , but that should be OK since the original test already finished, and I believe that's the currently expected behaviour. It's not a silver bullet solution to flaky tests, but it should help us quite a lot.
What do you think? Is it OK if I open a Pull Request? Or do you think there may be a better approach?
Here's the full stacktrace and some logs of the crash:
The text was updated successfully, but these errors were encountered: