From ced82528cfd41fcdbb1bf6c75fc9ada8b9f5d5a7 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Wed, 20 Oct 2021 07:49:39 +0200 Subject: [PATCH] Harden another race condition in ReplicatedEventSourcingSpec, #30783 (#30784) --- .../typed/ReplicatedEventSourcingSpec.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ReplicatedEventSourcingSpec.scala b/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ReplicatedEventSourcingSpec.scala index efe9b8415e..37daf15099 100644 --- a/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ReplicatedEventSourcingSpec.scala +++ b/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ReplicatedEventSourcingSpec.scala @@ -252,15 +252,15 @@ class ReplicatedEventSourcingSpec val eventProbeR2 = createTestProbe[EventAndContext]() val r1 = spawn(testBehavior(entityId, "R1", eventProbeR1.ref)) val r2 = spawn(testBehavior(entityId, "R2", eventProbeR2.ref)) - val latch1 = new CountDownLatch(1) - val latch2 = new CountDownLatch(1) - r1 ! StoreMe("from r1", probe.ref, latch1) // R1 0 R2 0 -> R1 1 R2 0 - r2 ! StoreMe("from r2", probe.ref, latch2) // R2 0 R1 0 -> R2 1 R1 0 + val latch = new CountDownLatch(3) + r1 ! StoreMe("from r1", probe.ref, latch) // R1 0 R2 0 -> R1 1 R2 0 + r2 ! StoreMe("from r2", probe.ref, latch) // R2 0 R1 0 -> R2 1 R1 0 // the commands have arrived in both actors, waiting for the latch, // so that the persist of the events will be concurrent - latch1.countDown() - latch2.countDown() + latch.countDown() + latch.await(10, TimeUnit.SECONDS) + latch.countDown() // each gets its local event eventProbeR1.expectMessage(