Skip to content

Commit 06d14fb

Browse files
committed
fix await latch
1 parent b7fe664 commit 06d14fb

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/analytics/BackendInfoHolder.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ class BackendInfoHolder : Disposable {
6666
return aboutRef.get()
6767
}
6868

69+
fun getAboutLoadIfNull(): AboutResult? {
70+
if (aboutRef.get() == null) {
71+
findActiveProject()?.let {
72+
loadAboutInBackgroundNow(it)
73+
}
74+
}
75+
return aboutRef.get()
76+
}
77+
78+
6979
//updateInBackground is also called every time the analytics client is replaced
7080
fun updateInBackground() {
7181
@Suppress("UnstableApiUsage")
@@ -122,4 +132,23 @@ class BackendInfoHolder : Disposable {
122132
false
123133
}
124134
}
135+
136+
private fun loadAboutInBackgroundNow(project: Project) {
137+
138+
try {
139+
140+
val future = Backgroundable.ensurePooledThreadWithoutReadAccess(Callable {
141+
AnalyticsService.getInstance(project).about
142+
})
143+
144+
aboutRef.set(future.get(5, TimeUnit.SECONDS))
145+
146+
} catch (e: Throwable) {
147+
val isConnectionException = ExceptionUtils.isAnyConnectionException(e)
148+
149+
if (!isConnectionException) {
150+
ErrorReporter.getInstance().reportError("BackendUtilsKt.isCentralized", e)
151+
}
152+
}
153+
}
125154
}

src/main/kotlin/org/digma/intellij/plugin/ui/common/LoadStatusPanel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class LoadStatusPanel(val project: Project) : DigmaResettablePanel() {
134134
private fun shouldDisplayCloseButton(): Boolean
135135
{
136136

137-
val version = BackendInfoHolder.getInstance().getAbout()?.applicationVersion ?: return false
137+
val version = BackendInfoHolder.getInstance().getAboutLoadIfNull()?.applicationVersion ?: return false
138138

139139
val currentBackendVersion = ComparableVersion(version)
140140
val closeButtonBackendVersion = ComparableVersion("0.3.25")

0 commit comments

Comments
 (0)