@Test public void create() throws ExecutionException, InterruptedException { Multi<Integer> publisher = Multi.createFrom().items(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .emitOn(executor); List<Integer> list = ReactiveStreams.<Integer> failed(new Exception("BOOM")) .onErrorResumeWith(t -> ReactiveStreams.fromPublisher(publisher)) .toList() .run().toCompletableFuture().exceptionally(x -> Collections.emptyList()).get(); assertThat(list).hasSize(10); }
@SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage) { Function<Throwable, Graph> function = Objects.requireNonNull(stage).getFunction(); Objects.requireNonNull(function); return source -> (Multi<O>) source.onFailure().recoverWithMulti(failure -> { Graph graph = function.apply(failure); Publisher<I> publisher = engine.buildPublisher(Objects.requireNonNull(graph)); return Multi.createFrom().publisher(publisher); }); }
OnErrorResumeWithStageFactory implements ProcessingStageFactory<Stage.OnErrorResumeWith> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage) { Function<Throwable, Graph> function = Objects.requireNonNull(stage).getFunction(); Objects.requireNonNull(function); return source -> (Multi<O>) source.onFailure().recoverWithMulti(failure -> { Graph graph = function.apply(failure); Publisher<I> publisher = engine.buildPublisher(Objects.requireNonNull(graph)); return Multi.createFrom().publisher(publisher); }); } }
OnErrorResumeWithStageFactory implements ProcessingStageFactory<Stage.OnErrorResumeWith> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage) { Function<Throwable, Graph> function = Objects.requireNonNull(stage).getFunction(); Objects.requireNonNull(function); return source -> (Multi<O>) source.onFailure().recoverWithMulti(failure -> { Graph graph = function.apply(failure); Publisher<I> publisher = engine.buildPublisher(Objects.requireNonNull(graph)); return Multi.createFrom().publisher(publisher); }); }  }
OnErrorResumeWithStageFactory implements ProcessingStageFactory<Stage.OnErrorResumeWith> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage) { Function<Throwable, Graph> function = Objects.requireNonNull(stage).getFunction(); Objects.requireNonNull(function); return source -> (Multi<O>) source.onFailure().recoverWithMulti(failure -> { Graph graph = function.apply(failure); Publisher<I> publisher = engine.buildPublisher(Objects.requireNonNull(graph)); return Multi.createFrom().publisher(publisher); }); }  @SuppressWarnings("unchecked") @Override ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage); }
OnErrorResumeWithStageFactory implements ProcessingStageFactory<Stage.OnErrorResumeWith> { @SuppressWarnings("unchecked") @Override public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage) { Function<Throwable, Graph> function = Objects.requireNonNull(stage).getFunction(); Objects.requireNonNull(function); return source -> (Multi<O>) source.onFailure().recoverWithMulti(failure -> { Graph graph = function.apply(failure); Publisher<I> publisher = engine.buildPublisher(Objects.requireNonNull(graph)); return Multi.createFrom().publisher(publisher); }); }  @SuppressWarnings("unchecked") @Override ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage);  }