Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-02-21 08:24:03 +0000
committerEike Stepper2020-02-21 08:24:03 +0000
commit7d10d7c9d86eb2cad9ed5ac6df60bcb7a5f71b39 (patch)
tree80c928fcb72e6707ea87215d1d2f4f963837e617 /plugins/org.eclipse.emf.cdo.common/src
parent4c5cc26ab9266fcd3b0fcbb3d620b162f5234b1d (diff)
downloadcdo-7d10d7c9d86eb2cad9ed5ac6df60bcb7a5f71b39.tar.gz
cdo-7d10d7c9d86eb2cad9ed5ac6df60bcb7a5f71b39.tar.xz
cdo-7d10d7c9d86eb2cad9ed5ac6df60bcb7a5f71b39.zip
[560280] Possible deadlock during the session invalidation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=560280
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java11
4 files changed, 35 insertions, 8 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java
index 6635d4ae39..6d0cf8f1ae 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java
@@ -21,6 +21,7 @@ import org.eclipse.net4j.util.event.INotifier;
import org.eclipse.emf.ecore.EClass;
import java.util.List;
+import java.util.function.Consumer;
/**
* Caches {@link CDORevision revisions} and possibly {@link EvictionEvent evicts} those that are no longer strongly
@@ -58,6 +59,13 @@ public interface CDORevisionCache extends CDORevisionCacheAdder, INotifier
public List<CDORevision> getCurrentRevisions();
/**
+ * Passes each {@link CDORevision revision} that is current into the given consumer.
+ *
+ * @since 4.9
+ */
+ public void forEachCurrentRevision(Consumer<CDORevision> consumer);
+
+ /**
* An {@link IEvent event} fired from a {@link CDORevisionCache revision cache} for {@link CDORevision revisions} that
* are evicted because they are no longer strongly referenced when free memory runs low.
*
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java
index f8510b489a..0a6ffc410e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java
@@ -35,6 +35,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.function.Consumer;
/**
* @author Eike Stepper
@@ -108,6 +109,13 @@ public class CDORevisionCacheAuditing extends AbstractCDORevisionCache
public List<CDORevision> getCurrentRevisions()
{
List<CDORevision> currentRevisions = new ArrayList<>();
+ forEachCurrentRevision(r -> currentRevisions.add(r));
+ return currentRevisions;
+ }
+
+ @Override
+ public void forEachCurrentRevision(Consumer<CDORevision> consumer)
+ {
synchronized (revisionLists)
{
for (RevisionList revisionList : revisionLists.values())
@@ -115,12 +123,10 @@ public class CDORevisionCacheAuditing extends AbstractCDORevisionCache
InternalCDORevision revision = revisionList.getRevision(CDORevision.UNSPECIFIED_DATE);
if (revision != null)
{
- currentRevisions.add(revision);
+ consumer.accept(revision);
}
}
}
-
- return currentRevisions;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
index 1e817ebb5c..89935ec366 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.function.Consumer;
/**
* @author Eike Stepper
@@ -113,6 +114,13 @@ public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache
public List<CDORevision> getCurrentRevisions()
{
List<CDORevision> currentRevisions = new ArrayList<>();
+ forEachCurrentRevision(r -> currentRevisions.add(r));
+ return currentRevisions;
+ }
+
+ @Override
+ public void forEachCurrentRevision(Consumer<CDORevision> consumer)
+ {
synchronized (revisions)
{
for (Reference<InternalCDORevision> ref : revisions.values())
@@ -120,12 +128,10 @@ public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache
InternalCDORevision revision = ref.get();
if (revision != null && !revision.isHistorical())
{
- currentRevisions.add(revision);
+ consumer.accept(revision);
}
}
}
-
- return currentRevisions;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java
index 801496c2af..ae3fd7333b 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java
@@ -25,6 +25,7 @@ import org.eclipse.emf.ecore.EClass;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.function.Consumer;
/**
* @author Eike Stepper
@@ -33,7 +34,7 @@ public class NOOPRevisionCache extends Lifecycle implements InternalCDORevisionC
{
public static final NOOPRevisionCache INSTANCE = new NOOPRevisionCache();
- private static final List<CDORevision> EMPTY = Collections.emptyList();
+ private static final List<CDORevision> EMPTY_LIST = Collections.emptyList();
public NOOPRevisionCache()
{
@@ -59,7 +60,13 @@ public class NOOPRevisionCache extends Lifecycle implements InternalCDORevisionC
@Override
public List<CDORevision> getCurrentRevisions()
{
- return EMPTY;
+ return EMPTY_LIST;
+ }
+
+ @Override
+ public void forEachCurrentRevision(Consumer<CDORevision> consumer)
+ {
+ // Do nothing.
}
public InternalCDORevision getRevision(CDOID id)

Back to the top