From 27e557bd83c308a5f4828c7b7c89fbd17c62b45e Mon Sep 17 00:00:00 2001 From: Terry Brady Date: Wed, 28 Sep 2016 10:21:21 -0700 Subject: [PATCH] Prevent concurrent modification exception --- .../org/dspace/app/itemimport/ItemImportServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java index 176d82b451..e424e75e6c 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java @@ -561,10 +561,16 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea { if (!isTest) { + ArrayList removeList = new ArrayList<>(); List collections = myitem.getCollections(); - // Remove item from all the collections it's in + // Save items to be removed to prevent concurrent modification exception DS-3322 for (Collection collection : collections) { + removeList.add(collection); + } + + // Remove item from all the collections it's in + for (Collection collection : removeList) { collectionService.removeItem(c, collection, myitem); } }