diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/HubSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/HubSpec.scala index 14144b04e0..85b6f5e31f 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/HubSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/HubSpec.scala @@ -313,6 +313,10 @@ class HubSpec extends StreamSpec { downstream1.request(4) downstream2.request(8) + // sending the first element is in a race with downstream subscribing + // give a bit of time for the downstream to complete subscriptions + Thread.sleep(50) + (1 to 8) foreach (upstream.sendNext(_)) downstream1.expectNext(1, 2, 3, 4) @@ -576,6 +580,10 @@ class HubSpec extends StreamSpec { downstream1.request(4) downstream2.request(8) + // to make sure downstream subscriptions are done before + // starting to send elements + Thread.sleep(50) + (0 until 16) foreach (upstream.sendNext(_)) downstream1.expectNext(0, 2, 4, 6)