diff --git a/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java b/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java index 2be07dec44b6..cc9f2d1dd422 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java +++ b/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java @@ -18,6 +18,7 @@ package com.intellij.util.indexing.impl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.SystemProperties; import com.intellij.util.containers.hash.LinkedHashMap; +import com.intellij.util.indexing.IndexId; import com.intellij.util.io.KeyDescriptor; import java.util.Collection; @@ -26,6 +27,8 @@ import java.util.Formatter; public class DebugAssertions { private static final Logger LOG = Logger.getInstance(DebugAssertions.class); + public static final ThreadLocal DEBUG_INDEX_ID = new ThreadLocal<>(); + @SuppressWarnings("StaticNonFinalField") public static volatile boolean DEBUG = SystemProperties.getBooleanProperty( "intellij.idea.indices.debug", diff --git a/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java b/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java index 4e3c0c544ade..5e0a3b2ed4c4 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java +++ b/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java @@ -236,11 +236,11 @@ public abstract class MapReduceIndex implements InvertedIndex< if (myDisposed) { return new ValueContainerImpl<>(); } - ValueContainerImpl.ourDebugIndexInfo.set(myIndexId); + DebugAssertions.DEBUG_INDEX_ID.set(myIndexId); return myStorage.read(key); } finally { - ValueContainerImpl.ourDebugIndexInfo.set(null); + DebugAssertions.DEBUG_INDEX_ID.set(null); lock.unlock(); } } @@ -354,9 +354,9 @@ public abstract class MapReduceIndex implements InvertedIndex< @NotNull UpdateData updateData) throws StorageException { getWriteLock().lock(); try { - IndexId oldIndexId = ValueContainerImpl.ourDebugIndexInfo.get(); + IndexId oldIndexId = DebugAssertions.DEBUG_INDEX_ID.get(); try { - ValueContainerImpl.ourDebugIndexInfo.set(myIndexId); + DebugAssertions.DEBUG_INDEX_ID.set(myIndexId); boolean hasDifference = updateData.iterateKeys(myAddedKeyProcessor, myUpdatedKeyProcessor, myRemovedKeyProcessor); if (hasDifference) updateData.updateForwardIndex(); } @@ -367,7 +367,7 @@ public abstract class MapReduceIndex implements InvertedIndex< throw new StorageException(e); } finally { - ValueContainerImpl.ourDebugIndexInfo.set(oldIndexId); + DebugAssertions.DEBUG_INDEX_ID.set(oldIndexId); } } finally { diff --git a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java index e2c6a6b2045d..0555e70c21a9 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java +++ b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java @@ -98,8 +98,6 @@ class ValueContainerImpl extends UpdatableValueContainer implement return myInputIdMapping != null ? myInputIdMapping instanceof THashMap ? ((THashMap)myInputIdMapping).size(): 1 : 0; } - static final ThreadLocal ourDebugIndexInfo = new ThreadLocal<>(); - @Override public void removeAssociatedValue(int inputId) { if (myInputIdMapping == null) return; @@ -114,7 +112,7 @@ class ValueContainerImpl extends UpdatableValueContainer implement valueObjects = new SmartList<>(); } else if (DebugAssertions.DEBUG) { - LOG.error("Expected only one value per-inputId for " + ourDebugIndexInfo.get(), String.valueOf(fileSetObjects.get(0)), String.valueOf(value)); + LOG.error("Expected only one value per-inputId for " + DebugAssertions.DEBUG_INDEX_ID.get(), String.valueOf(fileSetObjects.get(0)), String.valueOf(value)); } fileSetObjects.add(valueIterator.getFileSetObject()); valueObjects.add(value);