When I call the remote interface with the tool class RestTemplate,I sometimes encounter the following errors :

SpringBoot Using RestTemplate to call the interface,an exception occurred,java.util.ConcurrentModificationException: null

I checked some data and learned that the error was caused by manipulating (such as deleting) elements when looping elements, but I could hardly find a match in my code.

And not every time this error will occur, very few cases will occur.

Using SpringBoot version-2.2.6.RELEASE

Comment From: wilkinsona

This problem will occur if one thread changes a RestTemplate's message converters while another thread is using it to send a request. Neither Spring Boot nor Spring Framework itself will do that so I believe the problem must be in your application's code or another library that it is using. If you need some help identifying the cause, please follow up on Stack Overflow or Gitter.

Comment From: C644753271

Yes, as you said, I also found this problem. Thank you very much for your answer

Comment From: zios07

@wilkinsona Thank you, that was helpful in my case as well !

Comment From: takanuva15

@C644753271 hi, i'm seeing this issue in my spring boot server too lol. Could you share some info about where you found that your app was changing the resttemplate's messageconverters? I cant seem to find anything that would make that happen in my codebase

EDIT: After further examination, it turns out someone was modifying the MessageConverters during an API call in our codebase through this line:

restTemplate.setMessageConverters(messageConverters);

So try just looking in the code for "messageconverter" and you might find something fishy lol

Comment From: venkatnaidu123

What is the solution for the issue?

Comment From: bclozel

@venkatnaidu123 it is all explained in the comments above.