This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new b0f9779b47 test: fix flaky 'stop an underutilizationStreak when fully
utilized' on JDK 25 (#2898)
b0f9779b47 is described below
commit b0f9779b473b66c5ca45efc90430deefe7b9accf
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Fri Apr 24 17:40:50 2026 +0800
test: fix flaky 'stop an underutilizationStreak when fully utilized' on JDK
25 (#2898)
Motivation:
The test failed intermittently on JDK 25 CI:
Some(UnderUtilizationStreak(..., 1)) was not empty (line 155)
Same race condition previously addressed in #2769 for the sibling test:
`sendToAll(await = true)` only guarantees each routee has *started*
processing (the first latch counted down), not that the resizer's later
inspection of `cell.currentMessage` will observe a non-null reference.
Under JDK 25's scheduling there is a brief window where currentMessage
can appear null while the actor transitions, causing `utilized` to be
computed as 1 instead of 2 and the underutilization streak to persist.
Modification:
After `sendToAll(await = true)`, enqueue one extra message per routee
with `await = false` so the mailbox is non-empty even if currentMessage
is momentarily indeterminate. Mirrors the fix already applied to
"update the underutilizationStreak highestUtilization if current
utilization is higher".
Result:
The test deterministically observes utilized == 2 on JDK 25 and the
underutilization streak is cleared as expected.
---
.../test/scala/org/apache/pekko/routing/MetricsBasedResizerSpec.scala | 4 ++++
1 file changed, 4 insertions(+)
diff --git
a/actor-tests/src/test/scala/org/apache/pekko/routing/MetricsBasedResizerSpec.scala
b/actor-tests/src/test/scala/org/apache/pekko/routing/MetricsBasedResizerSpec.scala
index 3642c07a3d..59cf8343d0 100644
---
a/actor-tests/src/test/scala/org/apache/pekko/routing/MetricsBasedResizerSpec.scala
+++
b/actor-tests/src/test/scala/org/apache/pekko/routing/MetricsBasedResizerSpec.scala
@@ -150,6 +150,10 @@ class MetricsBasedResizerSpec extends
PekkoSpec(ResizerSpec.config) with Default
val router = TestRouter(routees(2))
router.sendToAll(await = true)
+ // Send additional messages to ensure mailbox is non-empty when checked,
+ // avoiding a race condition where currentMessage could be null
momentarily
+ router.mockSend(await = false, routeeIdx = 0)
+ router.mockSend(await = false, routeeIdx = 1)
resizer.reportMessageCount(router.routees, router.msgs.size)
resizer.record.underutilizationStreak shouldBe empty
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]