From 0a80cddb3b3dc49e087a7e6ba3f3dfc5e08aad89 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Wed, 15 Jul 2015 13:57:12 +0200 Subject: [PATCH] avoid synchronous index rebuild in tests to avoid problems with read action at hand --- .../src/com/intellij/util/indexing/FileBasedIndexImpl.java | 4 ++++ 1 file changed, 4 insertions(+) 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 a402139449cf..2861cb50a274 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -1210,6 +1210,10 @@ public class FileBasedIndexImpl extends FileBasedIndex { @Nullable public static Throwable getCauseToRebuildIndex(@NotNull RuntimeException e) { + if (ApplicationManager.getApplication().isUnitTestMode()) { + // avoid rebuilding index in tests since we do it synchronously in requestRebuild and we can have readAction at hand + return null; + } if (e instanceof IndexOutOfBoundsException) return e; // something wrong with direct byte buffer Throwable cause = e.getCause(); if (cause instanceof StorageException || cause instanceof IOException ||