Skip to content

Commit cfa77a9

Browse files
authored
fix error on EDT (#2001)
1 parent 9854b4c commit cfa77a9

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package org.digma.intellij.plugin.analytics
22

33
import com.fasterxml.jackson.databind.JsonNode
44
import com.intellij.util.messages.Topic
5-
import org.digma.intellij.plugin.model.rest.navigation.CodeLocation
6-
import org.digma.intellij.plugin.scope.SpanScope
75

86
interface InsightStatsChangedEvent {
97
companion object {

src/main/kotlin/org/digma/intellij/plugin/ui/jcef/BaseMessageRouterHandler.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import org.digma.intellij.plugin.log.Log
2525
import org.digma.intellij.plugin.model.rest.navigation.CodeLocation
2626
import org.digma.intellij.plugin.navigation.MainContentViewSwitcher
2727
import org.digma.intellij.plugin.posthog.ActivityMonitor
28-
import org.digma.intellij.plugin.scope.ScopeChangedEvent
2928
import org.digma.intellij.plugin.scope.ScopeManager
3029
import org.digma.intellij.plugin.scope.SpanScope
3130
import org.digma.intellij.plugin.ui.MainToolWindowCardsController
@@ -213,12 +212,12 @@ abstract class BaseMessageRouterHandler(protected val project: Project) : Common
213212
payload?.let {
214213
val scopeNode = payload.get("scope");
215214
if (scopeNode is NullNode){
216-
var stats = AnalyticsService.getInstance(project).getInsightsStats(null);
215+
val stats = AnalyticsService.getInstance(project).getInsightsStats(null);
217216
project.messageBus.syncPublisher(InsightStatsChangedEvent.INSIGHT_STATS_CHANGED_TOPIC)
218217
.insightStatsChanged(null, stats.analyticsInsightsCount, stats.issuesInsightsCount, stats.unreadInsightsCount)
219218
} else {
220-
var spanCodeObjectId = scopeNode.get("span").get("spanCodeObjectId").asText()
221-
var stats = AnalyticsService.getInstance(project).getInsightsStats(spanCodeObjectId);
219+
val spanCodeObjectId = scopeNode.get("span").get("spanCodeObjectId").asText()
220+
val stats = AnalyticsService.getInstance(project).getInsightsStats(spanCodeObjectId);
222221
project.messageBus.syncPublisher(InsightStatsChangedEvent.INSIGHT_STATS_CHANGED_TOPIC)
223222
.insightStatsChanged(scopeNode, stats.analyticsInsightsCount, stats.issuesInsightsCount, stats.unreadInsightsCount)
224223
}

src/main/kotlin/org/digma/intellij/plugin/ui/recentactivity/RecentActivityService.kt

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import kotlinx.coroutines.launch
1212
import org.digma.intellij.plugin.analytics.AnalyticsService
1313
import org.digma.intellij.plugin.analytics.AnalyticsServiceException
1414
import org.digma.intellij.plugin.common.EDT
15-
import org.digma.intellij.plugin.env.EnvironmentsSupplier
1615
import org.digma.intellij.plugin.errorreporting.ErrorReporter
1716
import org.digma.intellij.plugin.log.Log
1817
import org.digma.intellij.plugin.model.rest.recentactivity.RecentActivityResult
@@ -85,46 +84,23 @@ class RecentActivityService(val project: Project) : Disposable {
8584
Log.log(logger::trace, project, "processRecentActivityGoToSpanRequest called with {}", payload)
8685

8786
payload?.let {
88-
EDT.ensureEDT {
89-
90-
try {
91-
92-
//todo: we need to show the insights only after the environment changes. but environment change is done in the background
93-
// and its not easy to sync the change environment and showing the insights.
94-
// this actually comes to solve the case that the recent activity and the main environment combo
95-
// are not the same one and they need to sync. when this is fixed we can remove
96-
// the methods EnvironmentsSupplier.setCurrent(java.lang.String, boolean, java.lang.Runnable)
97-
// changing environment should be atomic and should not be effected by user activities like
98-
// clicking a link in recent activity
99-
100-
val spanId = payload.span.spanCodeObjectId
101-
spanId?.let {
102-
ScopeManager.getInstance(project).changeScope(SpanScope(spanId))
103-
project.service<ActivityMonitor>().registerSpanLinkClicked(MonitoredPanel.RecentActivity)
104-
}
105-
106-
} catch (e: Exception) {
107-
Log.warnWithException(logger, project, e, "error in processRecentActivityGoToSpanRequest")
108-
ErrorReporter.getInstance().reportError(project, "RecentActivityService.processRecentActivityGoToSpanRequest", e)
109-
}
87+
val spanId = payload.span.spanCodeObjectId
88+
spanId?.let {
89+
ScopeManager.getInstance(project).changeScope(SpanScope(spanId))
90+
ActivityMonitor.getInstance(project).registerSpanLinkClicked(MonitoredPanel.RecentActivity)
11091
}
11192
}
11293
}
11394

11495

11596
fun processRecentActivityGoToTraceRequest(payload: RecentActivityEntrySpanForTracePayload?) {
11697

117-
try {
118-
Log.log(logger::trace, project, "processRecentActivityGoToTraceRequest called with {}", payload)
98+
Log.log(logger::trace, project, "processRecentActivityGoToTraceRequest called with {}", payload)
11999

120-
if (payload != null) {
121-
openJaegerFromRecentActivity(project, payload.traceId, payload.span.scopeId, payload.span.spanCodeObjectId)
122-
} else {
123-
Log.log({ message: String? -> logger.debug(message) }, "processRecentActivityGoToTraceRequest payload is empty")
124-
}
125-
} catch (e: Exception) {
126-
Log.warnWithException(logger, project, e, "error in processRecentActivityGoToTraceRequest")
127-
ErrorReporter.getInstance().reportError(project, "RecentActivityService.processRecentActivityGoToTraceRequest", e)
100+
if (payload != null) {
101+
openJaegerFromRecentActivity(project, payload.traceId, payload.span.scopeId, payload.span.spanCodeObjectId)
102+
} else {
103+
Log.log({ message: String? -> logger.debug(message) }, "processRecentActivityGoToTraceRequest payload is empty")
128104
}
129105
}
130106

0 commit comments

Comments
 (0)