"Autobuild disabled" popup sometimes pops up multiple times

When Autobuilding is disabled, SonarQube for Eclipse shows a popup informing the user that results may be inaccurate.

However, if multiple build commands are issued at the same time, it occasionally happens that this popup is shown multiple times (I could not find a reliable reproduction for this, but this problem might occur when switching branches / pulling in new commits via the Eclipse Git integration).

Looking into the code shows that the cause of this problem happens in NoAutomaticBuildWarningPopup.displayPopupIfNotIgnored():

Checking PopupUtils.popupCurrentlyDisplayed(Class<? extends AbstractNotificationPopup>) should guard against this popup being shown multiple times.

However, this method is not checked again by the time the asynchronously scheduled runnable is actually executed, which leads to the described problem (This can also be reproduced by calling NoAutomaticBuildWarningPopup.displayPopupIfNotIgnored() in a loop repeatedly).

I’ve proposed a solution for this in Added asyncExec guard for autobuild disabled popup by r-mennig · Pull Request #1098 · SonarSource/sonarlint-eclipse · GitHub which re-checks the isAutoBuilding(), popupCurrentlyDisplayed(...) and noAutomaticBuildWarning() inside the async runnable.

  • Operating system: Windows
  • IDE name and version: Eclipse 4.40
  • SonarQube for Eclipse plugin version: 12.6.0.84813
  • Programming language you’re coding in: Java
  • Is connected mode used: Yes
    • SonarQube Cloud, SonarQube Server, or SonarQube Community Build? (if one of the latter two, which version?): SonarQube Community Build

I’ve just noticed the same issue is also present for the InvalidTokenPopup, LanguageFromConnectedModePopup, NewerVersionAvailablePopup, NoBindingSuggestionFoundPopup and the ReleaseNotesPopup (although it might not be a problem here, since these popups are not shown as frequently)

(SonarLintRpcClientSupportPopup does not have this issue, since the popup is shown synchronously)

I would like to point out that the fix provided by Robin is a standard practice in SWT. The documentation of both Display.syncExec and Display.asyncExec mention that the runnable will be invoked at the next reasonable opportunity i.e. the state of the application may have changed between the time the runnable was sent to the queue and the time it actually runs.

Any chance of getting this fix merged in the upcoming release?

Thank you in advance!

Thanks for the report and the analysis!

We’re working a fix that covers this popup and the other async notifications with the same race. Hopefully this will ship in one of the next SonarQube for Eclipse release.