Fix possible NPE in ClusterShardingLeaseSpec (#31161)

Set the test lease after variables have been initialised
This commit is contained in:
Peter Vlugter 2022-02-22 22:17:16 +13:00 committed by GitHub
parent 3faeffd9b1
commit 16e35f6ea9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,16 +64,16 @@ class TestLease(settings: LeaseSettings, system: ExtendedActorSystem) extends Le
val log = Logging(system, classOf[TestLease])
val probe = TestProbe()(system)
log.info("Creating lease {}", settings)
TestLeaseExt(system).setTestLease(settings.leaseName, this)
val initialPromise = Promise[Boolean]()
private val nextAcquireResult = new AtomicReference[Future[Boolean]](initialPromise.future)
private val nextCheckLeaseResult = new AtomicReference[Boolean](false)
private val currentCallBack = new AtomicReference[Option[Throwable] => Unit](_ => ())
log.info("Creating lease {}", settings)
TestLeaseExt(system).setTestLease(settings.leaseName, this)
def setNextAcquireResult(next: Future[Boolean]): Unit =
nextAcquireResult.set(next)