diff --git a/core/util.runtime/src/org/jetbrains/kotlin/storage/LockBasedStorageManager.java b/core/util.runtime/src/org/jetbrains/kotlin/storage/LockBasedStorageManager.java index bb6cf36c67f..fe8af81541e 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/storage/LockBasedStorageManager.java +++ b/core/util.runtime/src/org/jetbrains/kotlin/storage/LockBasedStorageManager.java @@ -326,6 +326,12 @@ public class LockBasedStorageManager implements StorageManager { return typedValue; } catch (Throwable throwable) { + if (ExceptionUtilsKt.isProcessCanceledException(throwable)) { + value = NotValue.NOT_COMPUTED; + //noinspection ConstantConditions + throw (RuntimeException)throwable; + } + if (value == NotValue.COMPUTING) { // Store only if it's a genuine result, not something thrown through recursionDetected() value = WrappedValues.escapeThrowable(throwable); @@ -414,7 +420,14 @@ public class LockBasedStorageManager implements StorageManager { return typedValue; } catch (Throwable throwable) { - if (throwable == error) throw storageManager.exceptionHandlingStrategy.handleException(throwable); + if (ExceptionUtilsKt.isProcessCanceledException(throwable)) { + cache.remove(input); + //noinspection ConstantConditions + throw (RuntimeException)throwable; + } + if (throwable == error) { + throw storageManager.exceptionHandlingStrategy.handleException(throwable); + } Object oldValue = cache.put(input, WrappedValues.escapeThrowable(throwable)); if (oldValue != NotValue.COMPUTING) { diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt index 2bda56778fb..6e0982f24f4 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt @@ -39,3 +39,11 @@ fun closeQuietly(closeable: Closeable?) { } } } + +fun Throwable.isProcessCanceledException(): Boolean { + var klass: Class = this.javaClass + while (true) { + if (klass.canonicalName == "com.intellij.openapi.progress.ProcessCanceledException") return true + klass = klass.superclass ?: return false + } +}