openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1819981 - /openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Date Wed, 03 Jan 2018 15:36:53 GMT
Author: ilgrosso
Date: Wed Jan  3 15:36:53 2018
New Revision: 1819981

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

Modified:
    openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java

Modified: openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=1819981&r1=1819980&r2=1819981&view=diff
==============================================================================
--- openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
(original)
+++ openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Wed Jan  3 15:36:53 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