chore: Test if materializerPromise is already completed first. (#2117)

This commit is contained in:
He-Pin(kerr) 2025-08-31 18:48:47 +08:00 committed by GitHub
parent 95820eda15
commit 39cbb3936e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -96,7 +96,11 @@ final class SystemMaterializer(system: ExtendedActorSystem) extends Extension {
val materializer: Materializer = {
// block on async creation to make it effectively final
Await.result(systemMaterializerPromise.future, materializerTimeout.duration)
val future = systemMaterializerPromise.future
future.value match {
case Some(value) => value.get
case _ => Await.result(future, materializerTimeout.duration)
}
}
}