in cassandra-launcher/src/main/scala/org/apache/pekko/persistence/cassandra/testkit/CassandraLauncher.scala [410:428]
private def waitForCassandraToListen(host: String, port: Int) = {
val deadline = AwaitListenTimeout.fromNow
@annotation.tailrec
def tryConnect(): Unit = {
val retry =
try {
new Socket(host, port).close()
false
} catch {
case _: IOException if deadline.hasTimeLeft() =>
Thread.sleep(AwaitListenPoll.toMillis)
true
case ioe: IOException =>
throw new RuntimeException(s"Cassandra did not start within $AwaitListenTimeout", ioe)
}
if (retry) tryConnect()
}
tryConnect()
}