pjfanning commented on code in PR #1053:
URL: https://github.com/apache/incubator-pekko/pull/1053#discussion_r1468444576


##########
stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/FlowMapWithResourceSpec.scala:
##########
@@ -410,6 +410,24 @@ class FlowMapWithResourceSpec extends 
StreamSpec(UnboundedMailboxConfig) {
       Await.result(promise.future, 3.seconds) shouldBe Done
     }
 
+    "will close the autocloseable resource" in {
+      val closedCounter = new AtomicInteger(0)
+      val create = () => new AutoCloseable {
+        override def close(): Unit = closedCounter.incrementAndGet()
+      }
+      val (pub, sub) = TestSource
+        .probe[Int]
+        .mapWithResource(create, (_, count) => count)
+        .toMat(TestSink.probe)(Keep.both)
+        .run()
+      sub.expectSubscription().request(2)
+      pub.sendNext(1)
+      sub.expectNext(1)
+      pub.sendComplete()
+      sub.expectComplete()
+      closedCounter.get shouldBe 1

Review Comment:
   and we need tests where the function fails so that we can see that the close 
still happens (but only after the function fails)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to