From 0bd9699d3db0431ea48745469a33934d66719df7 Mon Sep 17 00:00:00 2001 From: ofekby <39569540+ofekby@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:19:03 +0200 Subject: [PATCH] DEV2-4200: Fix cached inconsistent value (#702) * Change the status bar fields to be volatile to enforce that it is being read with the most updated value. * Change the status bar fields to be volatile to enforce that it is being read with the most updated value. * Formatting --- .../com/tabnine/statusBar/TabnineStatusBarWidget.java | 11 ++++++----- .../statusBar/TabnineSelfHostedStatusBarWidget.kt | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java b/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java index 95ef350e..3015afa0 100644 --- a/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java +++ b/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java @@ -31,18 +31,19 @@ public class TabnineStatusBarWidget extends EditorBasedWidget implements StatusBarWidget, StatusBarWidget.MultipleTextValuesPresentation { private static final String EMPTY_SYMBOL = "\u0000"; - private boolean isLimited = false; + private volatile boolean isLimited = false; - private Boolean isLoggedIn = getLastBinaryState().map(StateResponse::isLoggedIn).orElse(null); + private volatile Boolean isLoggedIn = + getLastBinaryState().map(StateResponse::isLoggedIn).orElse(null); - private ServiceLevel serviceLevel = + private volatile ServiceLevel serviceLevel = getLastBinaryState().map(StateResponse::getServiceLevel).orElse(null); - private CloudConnectionHealthStatus cloudConnectionHealthStatus = + private volatile CloudConnectionHealthStatus cloudConnectionHealthStatus = getLastBinaryState() .map(StateResponse::getCloudConnectionHealthStatus) .orElse(CloudConnectionHealthStatus.Ok); - @Nullable private Boolean isForcedRegistration = null; + @Nullable private volatile Boolean isForcedRegistration = null; public TabnineStatusBarWidget(@NotNull Project project) { super(project); diff --git a/TabnineSelfHosted/src/main/java/com/tabnineSelfHosted/statusBar/TabnineSelfHostedStatusBarWidget.kt b/TabnineSelfHosted/src/main/java/com/tabnineSelfHosted/statusBar/TabnineSelfHostedStatusBarWidget.kt index 39f6e385..2ca763bf 100644 --- a/TabnineSelfHosted/src/main/java/com/tabnineSelfHosted/statusBar/TabnineSelfHostedStatusBarWidget.kt +++ b/TabnineSelfHosted/src/main/java/com/tabnineSelfHosted/statusBar/TabnineSelfHostedStatusBarWidget.kt @@ -23,7 +23,9 @@ class TabnineSelfHostedStatusBarWidget(project: Project) : EditorBasedWidget(project), StatusBarWidget, MultipleTextValuesPresentation { + @Volatile private var userInfoResponse = UserInfoStateSingleton.instance.get() + @Volatile private var connectionHealthStatus = BinaryStateSingleton.instance.get()?.cloudConnectionHealthStatus