|
13 | 13 | import org.digma.intellij.plugin.model.rest.debugger.DebuggerEventRequest; |
14 | 14 | import org.digma.intellij.plugin.model.rest.errordetails.CodeObjectErrorDetails; |
15 | 15 | import org.digma.intellij.plugin.model.rest.errors.CodeObjectError; |
16 | | -import org.digma.intellij.plugin.model.rest.insights.*; |
| 16 | +import org.digma.intellij.plugin.model.rest.insights.CodeObjectInsight; |
| 17 | +import org.digma.intellij.plugin.model.rest.insights.CustomStartTimeInsightRequest; |
| 18 | +import org.digma.intellij.plugin.model.rest.insights.GlobalInsight; |
| 19 | +import org.digma.intellij.plugin.model.rest.insights.InsightsRequest; |
| 20 | +import org.digma.intellij.plugin.model.rest.insights.SpanHistogramQuery; |
17 | 21 | import org.digma.intellij.plugin.model.rest.usage.UsageStatusRequest; |
18 | 22 | import org.digma.intellij.plugin.model.rest.usage.UsageStatusResult; |
19 | 23 | import org.digma.intellij.plugin.notifications.NotificationUtil; |
|
34 | 38 | import java.net.UnknownHostException; |
35 | 39 | import java.net.http.HttpTimeoutException; |
36 | 40 | import java.time.Instant; |
37 | | -import java.util.*; |
| 41 | +import java.util.ArrayList; |
| 42 | +import java.util.Arrays; |
| 43 | +import java.util.Collections; |
| 44 | +import java.util.HashMap; |
| 45 | +import java.util.List; |
| 46 | +import java.util.Map; |
| 47 | +import java.util.Objects; |
38 | 48 | import java.util.concurrent.TimeUnit; |
| 49 | +import java.util.concurrent.atomic.AtomicBoolean; |
39 | 50 | import java.util.function.Supplier; |
40 | 51 | import java.util.stream.Collectors; |
41 | 52 |
|
@@ -305,6 +316,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl |
305 | 316 |
|
306 | 317 | //reset status on success call |
307 | 318 | if (status.isInConnectionError()) { |
| 319 | + // change status here because connectionGained() will trigger call to this invoke() again |
| 320 | + // and without changing the status Notification will be displayed several times in a loop |
| 321 | + status.ok(); |
308 | 322 | NotificationUtil.showNotification(project, "Digma: Connection reestablished !"); |
309 | 323 | project.getMessageBus().syncPublisher(AnalyticsServiceConnectionEvent.ANALYTICS_SERVICE_CONNECTION_EVENT_TOPIC).connectionGained(); |
310 | 324 | } |
@@ -463,29 +477,29 @@ private static class Status { |
463 | 477 |
|
464 | 478 | private final Map<String, Boolean> errorsHistory = new HashMap<>(); |
465 | 479 |
|
466 | | - private boolean hadConnectException = false; |
| 480 | + private final AtomicBoolean hadConnectException = new AtomicBoolean(false); |
467 | 481 | private boolean hadError = false; |
468 | 482 |
|
469 | 483 | boolean isInError() { |
470 | | - return hadConnectException || hadError; |
| 484 | + return hadConnectException.get() || hadError; |
471 | 485 | } |
472 | 486 |
|
473 | 487 | boolean isInConnectionError() { |
474 | | - return hadConnectException; |
| 488 | + return hadConnectException.get(); |
475 | 489 | } |
476 | 490 |
|
477 | 491 | boolean isOk() { |
478 | 492 | return !isInError(); |
479 | 493 | } |
480 | 494 |
|
481 | 495 | public void ok() { |
482 | | - hadConnectException = false; |
| 496 | + hadConnectException.set(false); |
483 | 497 | hadError = false; |
484 | 498 | errorsHistory.clear(); |
485 | 499 | } |
486 | 500 |
|
487 | 501 | public void connectError() { |
488 | | - hadConnectException = true; |
| 502 | + hadConnectException.set(true); |
489 | 503 | } |
490 | 504 |
|
491 | 505 |
|
|
0 commit comments