Closed
Description
minimized code
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
class A() {
val bc = B.C(50)
}
object A {
Thread.sleep(100L)
val a = new A()
}
object B {
Thread.sleep(100L)
case class C(a: Int)
val a: A = A.a
}
object Repro {
final def main(args: Array[String]): Unit = {
Await.result(Future.sequence(Seq(
Future { A.a },
Future { B.a },
)), 1.seconds)
}
}
Compilation output
[error] Exception in thread "main" java.util.concurrent.TimeoutException: Future timed out after [1 second]
expectation
I would expect initialization to not deadlock. This snippet does not deadlock in scala 2.x.
The sleep
s are there just to make the issue more easily reproducible, without it the issue is still present, but intermittent.
I see no reason for the initialization to deadlock: initializing an instance of A
does not require object B
to be initialized as case class C
does not reference any fields on object B
.