diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java index c3c7dbe12..5e802109c 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java @@ -270,6 +270,7 @@ public class DataCacheStoreManager idList.add(holder.sm.getObjectId()); } + List removes = new ArrayList(); Map pcdatas = cache.getAll(idList); for (Entry entry : pcdatas.entrySet()) { Integer index = ids.get(entry.getKey()); @@ -277,10 +278,13 @@ public class DataCacheStoreManager PCDataHolder holder = (PCDataHolder) holders.get(index); if (oldpc != null && compareVersion(holder.sm, holder.sm.getVersion(), oldpc.getVersion()) == VERSION_EARLIER) - holders.remove(index); + removes.add(holder); else holders.set(index, holder.pcdata); } + + for (PCDataHolder holder : removes) + holders.remove(holder); } /**