Skip to content

Commit 35b88a8

Browse files
He-PinCopilot
andauthored
fix: port ExpiringLfuCacheSpec race fix (#978)
Port akka-http commit 87c9bdcbc by replacing a fixed sleep with awaitAssert in the cache capacity test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7917862 commit 35b88a8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

http-caching/src/test/scala/org/apache/pekko/http/caching/ExpiringLfuCacheSpec.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.apache.pekko
2323
import pekko.actor.ActorSystem
2424
import pekko.http.caching.scaladsl.CachingSettings
2525
import pekko.testkit.TestKit
26+
import pekko.testkit.TestProbe
2627

2728
import org.scalatest.BeforeAndAfterAll
2829
import org.scalatest.matchers.should.Matchers
@@ -125,8 +126,10 @@ class ExpiringLfuCacheSpec extends AnyWordSpec with Matchers with BeforeAndAfter
125126
Await.result(cache(2, () => Future.successful("B")), 3.seconds) should be("B")
126127
Await.result(cache.get(3, () => "C"), 3.seconds) should be("C")
127128
cache.get(4, () => "D")
128-
Thread.sleep(50)
129-
cache.size should be(3)
129+
val probe = TestProbe()
130+
probe.awaitAssert {
131+
cache.size should be(3)
132+
}
130133
}
131134
"not cache exceptions" in {
132135
val cache = lfuCache[String]()

0 commit comments

Comments
 (0)