From ffb4ee68dcd198b84d97e5395908ece44edaf179 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Wed, 19 Apr 2017 12:36:31 +0300 Subject: [PATCH] javac ast indices: request index rebuild if corruption exception is thrown from compressor --- .../CompilerReferenceServiceImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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; + } }