Skip to content

Commit

Permalink
DEV2-4200: Fix cached inconsistent value (#702)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ofekby authored Dec 6, 2023
1 parent b9edced commit 0bd9699
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0bd9699

Please sign in to comment.