diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 67e56536b4ba..63d7caa34549 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -988,12 +988,12 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent, final MapReduceIndex index = (MapReduceIndex)state.getIndex(indexId); assert index != null; final MemoryIndexStorage memStorage = (MemoryIndexStorage)index.getStorage(); - index.getWriteLock().lock(); + index.getReadLock().lock(); try { memStorage.clearCaches(); } finally { - index.getWriteLock().unlock(); + index.getReadLock().unlock(); } } } 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 3776a65dcf87..b0afa3cdab0b 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java +++ b/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java @@ -59,14 +59,13 @@ public abstract class MapReduceIndex implements InvertedIndex< @Override public void run() { try { - Lock writeLock = getWriteLock(); - if (writeLock.tryLock()) { - try { - myStorage.clearCaches(); - } finally { - writeLock.unlock(); - } + getReadLock().lock(); + try { + myStorage.clearCaches(); + } finally { + getReadLock().unlock(); } + flush(); } catch (Throwable e) { requestRebuild(e);