From e7b1b1cb8c9fcc060db2504790de398aafbfe667 Mon Sep 17 00:00:00 2001 From: Ofek Ben-Yaish Date: Wed, 6 Dec 2023 17:44:26 +0200 Subject: [PATCH 1/3] Change the status bar fields to be volatile to enforce that it is being read with the most updated value. --- .../statusBar/TabnineSelfHostedStatusBarWidget.kt | 2 ++ 1 file changed, 2 insertions(+) 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 From e49ef0a055dd309cd6b12afd6067d91267446033 Mon Sep 17 00:00:00 2001 From: Ofek Ben-Yaish Date: Wed, 6 Dec 2023 17:46:06 +0200 Subject: [PATCH 2/3] Change the status bar fields to be volatile to enforce that it is being read with the most updated value. --- .../com/tabnine/statusBar/TabnineStatusBarWidget.java | 10 +++++----- 1 file changed, 5 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..354a8f7d 100644 --- a/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java +++ b/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java @@ -31,18 +31,18 @@ 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); From 7f6d23019709f247c52bdd2483708b1e31f705b6 Mon Sep 17 00:00:00 2001 From: Ofek Ben-Yaish Date: Wed, 6 Dec 2023 17:48:54 +0200 Subject: [PATCH 3/3] Formatting --- .../java/com/tabnine/statusBar/TabnineStatusBarWidget.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java b/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java index 354a8f7d..3015afa0 100644 --- a/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java +++ b/Tabnine/src/main/java/com/tabnine/statusBar/TabnineStatusBarWidget.java @@ -33,7 +33,8 @@ public class TabnineStatusBarWidget extends EditorBasedWidget private static final String EMPTY_SYMBOL = "\u0000"; private volatile boolean isLimited = false; - private volatile Boolean isLoggedIn = getLastBinaryState().map(StateResponse::isLoggedIn).orElse(null); + private volatile Boolean isLoggedIn = + getLastBinaryState().map(StateResponse::isLoggedIn).orElse(null); private volatile ServiceLevel serviceLevel = getLastBinaryState().map(StateResponse::getServiceLevel).orElse(null);