openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1819982 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Date Wed, 03 Jan 2018 15:37:54 GMT
Author: ilgrosso
Date: Wed Jan  3 15:37:54 2018
New Revision: 1819982

URL: http://svn.apache.org/viewvc?rev=1819982&view=rev
Log:
OPENJPA-2725 - fix ConcurrentModificationException during unrefed dependents cleanup / thanks
@eran-levy - This closes #9

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=1819982&r1=1819981&r2=1819982&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java Wed
Jan  3 15:37:54 2018
@@ -2149,8 +2149,14 @@ public class BrokerImpl implements Broke
             // 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);
             }
 



Mime
View raw message