This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch stabilize-flaky-resizer-autocloseable
in repository https://gitbox.apache.org/repos/asf/pekko.git

commit ff3c53ed6212300483ea3ff9fe7627db3b294834
Author: He-Pin <[email protected]>
AuthorDate: Sat May 9 18:12:49 2026 +0800

    test: drop racy pre-shutdown closedCounter check in autocloseable 
abrupt-termination test
    
    Motivation:
    "will close the autocloseable resource on abrupt materializer
    termination" in FlowMapWithResourceSpec is intermittently flaky on
    JDK 21 / Scala 3.3.x nightly runs (failing in 22-115ms with
    "1 was not equal to 0" at FlowMapWithResourceSpec.scala:538).
    mapWithResource carries the IODispatcher attribute which lands the
    operator on a different dispatcher than Source.single and Sink.never,
    introducing an async-island bridge whose SubSink can pull eagerly.
    Once that pull propagates back, Source.single pushes its element and
    completes, StatefulMap.onUpstreamFinish fires, closeStateAndComplete
    runs the close callback and the AutoCloseable counter reaches 1 before
    the test thread issues mat.shutdown(). The pre-shutdown
    "closedCounter.get shouldBe 0" therefore loses the race on fast
    JDK21+ scheduling.
    
    Modification:
    Remove the pre-shutdown closedCounter assertion. The test still proves
    the abrupt-termination contract via the Await on created.future
    (ensuring create() ran), the AbruptTerminationException assertion on
    the materialized value, the Await on promise.future (ensuring close()
    ran) and the post-shutdown closedCounter == 1 check.
    
    Result:
    Removes a timing assumption that doesn't reflect the operator's
    contract, while keeping the close-on-abrupt-termination guarantee
    under verification.
---
 .../scala/org/apache/pekko/stream/scaladsl/FlowMapWithResourceSpec.scala | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/FlowMapWithResourceSpec.scala
 
b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/FlowMapWithResourceSpec.scala
index a3c2f9b400..103d07ff09 100644
--- 
a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/FlowMapWithResourceSpec.scala
+++ 
b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/FlowMapWithResourceSpec.scala
@@ -535,7 +535,6 @@ class FlowMapWithResourceSpec extends 
StreamSpec(UnboundedMailboxConfig) {
         .mapWithResource(create, (_: AutoCloseable, count) => count)
         .runWith(Sink.never)(mat)
       Await.result(created.future, 3.seconds.dilated) shouldBe Done
-      closedCounter.get shouldBe 0
       mat.shutdown()
       matVal.failed.futureValue shouldBe an[AbruptTerminationException]
       Await.result(promise.future, 3.seconds.dilated) shouldBe Done


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to