Improve SuggestionsRepo initialization (#9808)

Added synchronization block to avoid race conditions.
This commit is contained in:
Hubert Plociniczak 2024-05-13 15:40:52 +02:00 committed by GitHub
parent c67218c1ed
commit ff28737252
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,9 +24,13 @@ class InMemorySuggestionsRepo(implicit ec: ExecutionContext)
override def init: Future[Unit] = {
Future {
if (db == null) {
db = new mutable.HashMap()
version = 0
index = 1
this.synchronized {
if (db == null) {
db = new mutable.HashMap()
version = 0
index = 1
}
}
}
}
}