Skip to content

Commit

Permalink
Avoid race conditions when asking the user to import a build.
Browse files Browse the repository at this point in the history
Previously, a race condiition could cause Metals to prompt the user
twice to import build changes. The duplicate prompt could cause some
test suites to become flaky. Now, we synchronize on the method that
prompts the user to ensure that we finish writing the digest
notification status in the H2 database before sending the next prompt.
  • Loading branch information
olafurpg committed Dec 15, 2019
1 parent f98ab96 commit 260821f
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -135,10 +135,14 @@ final class BloopInstall(
}
}

// NOTE(olafur) there's a chance that we get two build change notifications in
// a very short period due to duplicate `didSave` and file watching
// notificiations. This method is synchronized to prevent asking the user
// twice whether to import the build.
def runIfApproved(
buildTool: BuildTool,
digest: String
): Future[BloopInstallResult] = {
): Future[BloopInstallResult] = synchronized {
oldInstallResult(digest) match {
case Some(result) =>
scribe.info(s"skipping build import with status '${result.name}'")
Expand Down

0 comments on commit 260821f

Please sign in to comment.