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-projects-issues opened this issue Dec 19, 2016 · 2 comments
Assignees
Labels
in: test Issues in the test module type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

Attachments:

Referenced from: commits fcead67, 6e508f7

@spring-projects-issues
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(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-projects-issues
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
Labels
in: test Issues in the test module type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants