Skip to content

Commit 3058640

Browse files
authored
Merge pull request #2253 from digma-ai/ignore-AlreadyDisposedException
ignore-AlreadyDisposedException Closes #2244
2 parents b76d438 + f629fdb commit 3058640

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/posthog/PerformanceMetricsPosthogEventStartupActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.intellij.openapi.components.Service
66
import com.intellij.openapi.components.service
77
import com.intellij.openapi.diagnostic.Logger
88
import com.intellij.openapi.project.Project
9+
import com.intellij.serviceContainer.AlreadyDisposedException
910
import kotlinx.coroutines.CoroutineScope
1011
import kotlinx.coroutines.delay
1112
import kotlinx.coroutines.isActive
@@ -104,6 +105,10 @@ class ContinuousPerformanceMetricsReporter : Disposable {
104105
}
105106
}
106107

108+
} catch (e: AlreadyDisposedException) {
109+
//ignore this exception.
110+
// it may happen when closing projects because this class uses any active project when it needs one on every iteration,
111+
// and sometimes the project will close before the current iteration ends.
107112
} catch (e: Exception) {
108113
Log.warnWithException(logger, e, "failed in first time registerPerformanceMetrics")
109114
ErrorReporter.getInstance()
@@ -142,6 +147,10 @@ class ContinuousPerformanceMetricsReporter : Disposable {
142147

143148
delay(6.hours.inWholeMilliseconds)
144149

150+
} catch (e: AlreadyDisposedException) {
151+
//ignore this exception.
152+
// it may happen when closing projects because this class uses any active project when it needs one on every iteration,
153+
// and sometimes the project will close before the current iteration ends.
145154
} catch (e: Exception) {
146155
Log.warnWithException(logger, e, "failed in continuous registerPerformanceMetrics")
147156
ErrorReporter.getInstance()

0 commit comments

Comments
 (0)