Do not store ProcessCanceledException as result for cached value
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user