diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java index d77fa4fee8f7..7b312a1094af 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java @@ -57,6 +57,7 @@ import com.intellij.util.indexing.StorageException; import com.intellij.util.io.PersistentEnumeratorBase; import gnu.trove.THashSet; import gnu.trove.TIntHashSet; +import org.iq80.snappy.CorruptionException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -663,9 +664,9 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceServiceEx imp throw (ProcessCanceledException)e; } - Throwable unwrapped = e instanceof RuntimeException ? e.getCause() : e; LOG.error("an exception during " + actionName + " calculation", e); - if (unwrapped instanceof PersistentEnumeratorBase.CorruptedException || unwrapped instanceof StorageException) { + Throwable unwrapped = e instanceof RuntimeException ? e.getCause() : e; + if (requireIndexRebuild(unwrapped)) { closeReaderIfNeed(true); } return null; @@ -677,4 +678,14 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceServiceEx imp result.retainAll(set2.toArray()); return result; } + + private static boolean requireIndexRebuild(@Nullable Throwable exception) { + if (exception instanceof PersistentEnumeratorBase.CorruptedException || exception instanceof StorageException) { + return true; + } + if (exception instanceof IOException && exception.getCause() instanceof CorruptionException) { + return true; + } + return false; + } }