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

ConcurrentModificationException in AbstractRequestExpectationManager [SPR-15029] #19596

spring-projects-issues opened this issue Dec 19, 2016 · 2 comments
in: test Issues in the test module type: bug A general bug


Copy link

spring-projects-issues commented Dec 19, 2016

Alastair Paterson opened SPR-15029 and commented

We are using MockRestServiceServer in conjunction with expectations to conduct testing of our Spring application.

We have noticed that when a method under test invokes asynchronous network requests the MockRestServiceServer will occasionally throw a ConcurrentModificationException causing the test to fail. The issue is observed when using parallelStream() as well as other asynchronous methods. Reintroducing concurrency alleviates the issue.

Please find attached a trivial Spring Boot application that reproduces this issue.

Affects: 4.2.4, 4.3.4


Referenced from: commits fcead67, 6e508f7

Copy link
Collaborator Author

spring-projects-issues commented Jan 3, 2017

Rossen Stoyanchev commented

Stack trace from given example:

Caused by: java.util.ConcurrentModificationException
	at java.util.LinkedHashMap$LinkedHashIterator.nextNode(
	at java.util.LinkedHashMap$
	at org.springframework.test.web.client.AbstractRequestExpectationManager$RequestExpectationGroup.findExpectation(
	at org.springframework.test.web.client.UnorderedRequestExpectationManager.validateRequestInternal(
	at org.springframework.test.web.client.AbstractRequestExpectationManager.validateRequest(
	at org.springframework.test.web.client.MockRestServiceServer$MockClientHttpRequestFactory$1.executeInternal(
	at org.springframework.mock.http.client.MockClientHttpRequest.execute(
	at org.springframework.web.client.RestTemplate.doExecute(
	at org.springframework.web.client.RestTemplate.execute(
	at org.springframework.web.client.RestTemplate.getForObject(

Copy link
Collaborator Author

spring-projects-issues commented Jan 17, 2017

Rossen Stoyanchev commented

This should be fixed. I ran the sample a few times and I don't see the error any more after the fix. Thanks for the report and sample!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: test Issues in the test module type: bug A general bug
None yet

No branches or pull requests

2 participants