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

Closed
spring-issuemaster opened this issue Dec 19, 2016 · 2 comments

Comments

@spring-issuemaster
Copy link
Collaborator

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

Attachments:

Referenced from: commits fcead67, 6e508f7

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 3, 2017

Rossen Stoyanchev commented

Stack trace from given example:

Caused by: java.util.ConcurrentModificationException
	at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:711)
	at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:734)
	at org.springframework.test.web.client.AbstractRequestExpectationManager$RequestExpectationGroup.findExpectation(AbstractRequestExpectationManager.java:172)
	at org.springframework.test.web.client.UnorderedRequestExpectationManager.validateRequestInternal(UnorderedRequestExpectationManager.java:43)
	at org.springframework.test.web.client.AbstractRequestExpectationManager.validateRequest(AbstractRequestExpectationManager.java:72)
	at org.springframework.test.web.client.MockRestServiceServer$MockClientHttpRequestFactory$1.executeInternal(MockRestServiceServer.java:289)
	at org.springframework.mock.http.client.MockClientHttpRequest.execute(MockClientHttpRequest.java:94)
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:619)
	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580)
	at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:287)
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

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
Projects
None yet
2 participants
You can’t perform that action at this time.