OPENJPA-2725 - fix ConcurrentModificationException during unrefed dependents cleanup / thanks @eran-levy - This closes #9

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1819982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Francesco Chicchiriccò 2018-01-03 15:37:54 +00:00
parent b4c13fc0ed
commit 14d4b8007c
1 changed files with 8 additions and 2 deletions

View File

@ -2149,8 +2149,14 @@ public class BrokerImpl implements Broker, FindCallbacks, Cloneable, Serializabl
// dependents
_flags |= FLAG_DEREFDELETING;
if (flush && _derefCache != null && !_derefCache.isEmpty()) {
for (Iterator<StateManagerImpl> itr = _derefCache.iterator(); itr.hasNext();)
deleteDeref(itr.next());
Set<StateManagerImpl> statesMarkedForDelete = new HashSet<>();
// mark for delete all elements in deref, otherwise in some situations it
// throws ConcurrentModificationException
statesMarkedForDelete.addAll(_derefCache);
for (StateManagerImpl state: statesMarkedForDelete) {
deleteDeref(state);
}
flushAdditions(transactional, reason);
}