@Test public void mustBeAbleToRecover() throws Exception { final ManualProbe<Integer> publisherProbe = TestPublisher.manualProbe(true, system); final JavaTestKit probe = new JavaTestKit(system); final Source<Integer, NotUsed> source = Source.fromPublisher(publisherProbe) .map( elem -> { if (elem == 1) throw new RuntimeException("ex"); else return elem; }) .recover(new PFBuilder<Throwable, Integer>().matchAny(ex -> 0).build()); final CompletionStage<Done> future = source.runWith( Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer); final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription(); s.sendNext(0); probe.expectMsgEquals(0); s.sendNext(1); probe.expectMsgEquals(0); future.toCompletableFuture().get(200, TimeUnit.MILLISECONDS); }