@@ -547,35 +547,6 @@ class FlowMapWithResourceSpec extends StreamSpec(UnboundedMailboxConfig) {
547
547
closedCounter.get shouldBe 1
548
548
}
549
549
550
- " continue with autoCloseable when Strategy is Resume and exception happened on map" in {
551
- val closedCounter = new AtomicInteger (0 )
552
- val create = () =>
553
- new AutoCloseable {
554
- override def close (): Unit = closedCounter.incrementAndGet()
555
- }
556
- val p = Source
557
- .fromIterator(() => (0 to 50 ).iterator)
558
- .mapWithResource(create, (_ : AutoCloseable , elem) => elem)
559
- .map(elem => {
560
- if (elem == 10 ) throw TE (" " ) else elem
561
- })
562
- .withAttributes(supervisionStrategy(resumingDecider))
563
- .runWith(Sink .asPublisher(false ))
564
- val c = TestSubscriber .manualProbe[Int ]()
565
-
566
- p.subscribe(c)
567
- val sub = c.expectSubscription()
568
-
569
- (0 to 48 ).foreach(i => {
570
- sub.request(1 )
571
- c.expectNext() should === (if (i < 10 ) i else i + 1 )
572
- })
573
- sub.request(1 )
574
- c.expectNext(50 )
575
- c.expectComplete()
576
- closedCounter.get shouldBe 1
577
- }
578
-
579
550
" close and open stream with autocloseable again when Strategy is Restart" in {
580
551
val closedCounter = new AtomicInteger (0 )
581
552
val create = () =>
@@ -586,7 +557,7 @@ class FlowMapWithResourceSpec extends StreamSpec(UnboundedMailboxConfig) {
586
557
.fromIterator(() => (0 to 50 ).iterator)
587
558
.mapWithResource(create,
588
559
(_ : AutoCloseable , elem) => {
589
- if (elem == 10 ) throw TE (" " ) else elem
560
+ if (elem == 10 || elem == 20 ) throw TE (" " ) else elem
590
561
})
591
562
.withAttributes(supervisionStrategy(restartingDecider))
592
563
.runWith(Sink .asPublisher(false ))
@@ -595,9 +566,10 @@ class FlowMapWithResourceSpec extends StreamSpec(UnboundedMailboxConfig) {
595
566
p.subscribe(c)
596
567
val sub = c.expectSubscription()
597
568
598
- (0 to 18 ).foreach(i => {
569
+ (0 to 30 ).filter(i => i != 10 && i != 20 ).foreach(i => {
599
570
sub.request(1 )
600
- c.expectNext() should === (if (i < 10 ) i else i + 1 )
571
+ c.expectNext() shouldBe i
572
+ closedCounter.get should === (if (i < 10 ) 0 else if (i < 20 ) 1 else 2 )
601
573
})
602
574
sub.cancel()
603
575
}
0 commit comments