I am getting the following error:
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at org.apache.commons.lang3.StringUtils.join(StringUtils.java:3428)
at org.apache.commons.lang3.StringUtils.join(StringUtils.java:3513)
For running StringUtils.join
The StringUtils
documentation mentions: #ThreadSafe#
What is wrong? The code is located in a java class that implements Callable.
My full code:
public class MyApiCallable implements Callable<ResponseType> {
final List<String> itemsId;
MyApiCallable(List<String> itemsId) {
this.itemsId = itemsId;
}
@Override
public ResponseType call() throws Exception {
Client client = ClientBuilder.newClient();
WebTarget baseTarget = client.target("http://whatever.com").path("path").queryParam("ItemID", StringUtils.join(itemsId,",",));
ResponseType rs = target.request().get(ResponseType.class);
return rs;
}
}
and here is the method that calls the callable:
private Future<ResponseType> addGetMultipleItems(ExecutorService executor, List<String> itemIds) {
Callable<ResponseType> shoppingCallable = new MyApiCallable(itemIds);
Future<ResponseType> shoppingResult = executor.submit(shoppingCallable);
return shoppingResult;
}