From 781bc139410de3a68994c28ad0e09b840a769e3c Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 31 Mar 2016 19:14:53 +0300 Subject: [PATCH] ExceptionTracker: do not increment counter on ReenteringLazyValueComputationException ReenteringLazyValueComputationException is in fact correct behaviour which does not indicate a problem we should try to recover from This led to an obscure bug when resolve sessions were invalidated multiple times during light class construction (see KT-11635) #KT-11635 Fixed --- .../src/org/jetbrains/kotlin/storage/ExceptionTracker.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt b/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt index 0ec173c2442..6d767410213 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.storage import com.intellij.openapi.util.ModificationTracker +import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException import java.util.concurrent.atomic.AtomicLong import org.jetbrains.kotlin.utils.rethrow @@ -24,7 +25,10 @@ open class ExceptionTracker : ModificationTracker, LockBasedStorageManager.Excep private val cancelledTracker: AtomicLong = AtomicLong() override fun handleException(throwable: Throwable): RuntimeException { - incCounter() + // should not increment counter when ReenteringLazyValueComputationException is thrown since it implements correct frontend behaviour + if (throwable !is ReenteringLazyValueComputationException) { + incCounter() + } throw rethrow(throwable) }