Do not store ProcessCanceledException as result for cached value

This commit is contained in:
Valentin Kipyatkov
2017-06-01 17:13:35 +03:00
parent 09dbb07fb8
commit eb4f322c77
2 changed files with 22 additions and 1 deletions
@@ -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) {
@@ -39,3 +39,11 @@ fun closeQuietly(closeable: Closeable?) {
}
}
}
fun Throwable.isProcessCanceledException(): Boolean {
var klass: Class<out Any?> = this.javaClass
while (true) {
if (klass.canonicalName == "com.intellij.openapi.progress.ProcessCanceledException") return true
klass = klass.superclass ?: return false
}
}