From d0c1508422784eee129501b5eb6554da8ee6b194 Mon Sep 17 00:00:00 2001 From: Evgeny Pasynkov Date: Fri, 23 May 2014 10:48:12 +0200 Subject: [PATCH] syncronize 'assert' --- .../openapi/util/objectTree/ObjectTree.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java index 8b3978bb4930..f615a1cb5095 100644 --- a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java +++ b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java @@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.util.*; +import java.util.concurrent.atomic.AtomicLong; public final class ObjectTree { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.objectTree.ObjectTree"); @@ -41,7 +42,7 @@ public final class ObjectTree { final Object treeLock = new Object(); - private long myModification; + private AtomicLong myModification = new AtomicLong(0); public ObjectNode getNode(@NotNull T object) { synchronized (treeLock) { @@ -114,7 +115,7 @@ public final class ObjectTree { } public long getNextModification() { - return ++myModification; + return myModification.incrementAndGet(); } public final boolean executeAll(@NotNull T object, boolean disposeTree, @NotNull ObjectTreeAction action, boolean processUnregistered) { @@ -178,9 +179,11 @@ public final class ObjectTree { @TestOnly public void assertNoReferenceKeptInTree(@NotNull T disposable) { - Collection> nodes = myObject2NodeMap.values(); - for (ObjectNode node : nodes) { - node.assertNoReferencesKept(disposable); + synchronized (treeLock) { + Collection> nodes = myObject2NodeMap.values(); + for (ObjectNode node : nodes) { + node.assertNoReferencesKept(disposable); + } } } @@ -260,6 +263,6 @@ public final class ObjectTree { } public long getModification() { - return myModification; + return myModification.get(); } }