@@ -11770,19 +11770,19 @@ public final Flowable<T> retryUntil(final BooleanSupplier stop) {
1177011770 * resubscribe to the source Publisher.
1177111771 * <p>
1177211772 * <img width="640" height="430" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/retryWhen.f.png" alt="">
11773- *
11773+ * <p>
1177411774 * Example:
1177511775 *
1177611776 * This retries 3 times, each time incrementing the number of seconds it waits.
1177711777 *
1177811778 * <pre><code>
11779- * Publisher .create((Subscriber <? super String> s) -> {
11779+ * Flowable .create((FlowableEmitter <? super String> s) -> {
1178011780 * System.out.println("subscribing");
1178111781 * s.onError(new RuntimeException("always fails"));
11782- * }).retryWhen(attempts -> {
11782+ * }, BackpressureStrategy.BUFFER ).retryWhen(attempts -> {
1178311783 * return attempts.zipWith(Flowable.range(1, 3), (n, i) -> i).flatMap(i -> {
1178411784 * System.out.println("delay retry by " + i + " second(s)");
11785- * return Publisher .timer(i, TimeUnit.SECONDS);
11785+ * return Flowable .timer(i, TimeUnit.SECONDS);
1178611786 * });
1178711787 * }).blockingForEach(System.out::println);
1178811788 * </code></pre>
@@ -11798,9 +11798,35 @@ public final Flowable<T> retryUntil(final BooleanSupplier stop) {
1179811798 * delay retry by 3 second(s)
1179911799 * subscribing
1180011800 * } </pre>
11801+ * <p>
11802+ * Note that the inner {@code Publisher} returned by the handler function should signal
11803+ * either {@code onNext}, {@code onError} or {@code onComplete} in response to the received
11804+ * {@code Throwable} to indicate the operator should retry or terminate. If the upstream to
11805+ * the operator is asynchronous, signalling onNext followed by onComplete immediately may
11806+ * result in the sequence to be completed immediately. Similarly, if this inner
11807+ * {@code Publisher} signals {@code onError} or {@code onComplete} while the upstream is
11808+ * active, the sequence is terminated with the same signal immediately.
11809+ * <p>
11810+ * The following example demonstrates how to retry an asynchronous source with a delay:
11811+ * <pre><code>
11812+ * Flowable.timer(1, TimeUnit.SECONDS)
11813+ * .doOnSubscribe(s -> System.out.println("subscribing"))
11814+ * .map(v -> { throw new RuntimeException(); })
11815+ * .retryWhen(errors -> {
11816+ * AtomicInteger counter = new AtomicInteger();
11817+ * return errors
11818+ * .takeWhile(e -> counter.getAndIncrement() != 3)
11819+ * .flatMap(e -> {
11820+ * System.out.println("delay retry by " + counter.get() + " second(s)");
11821+ * return Flowable.timer(counter.get(), TimeUnit.SECONDS);
11822+ * });
11823+ * })
11824+ * .blockingSubscribe(System.out::println, System.out::println);
11825+ * </code></pre>
1180111826 * <dl>
1180211827 * <dt><b>Backpressure:</b></dt>
11803- * <dd>The operator honors downstream backpressure and expects the source {@code Publisher} to honor backpressure as well.
11828+ * <dd>The operator honors downstream backpressure and expects both the source
11829+ * and inner {@code Publisher}s to honor backpressure as well.
1180411830 * If this expectation is violated, the operator <em>may</em> throw an {@code IllegalStateException}.</dd>
1180511831 * <dt><b>Scheduler:</b></dt>
1180611832 * <dd>{@code retryWhen} does not operate by default on a particular {@link Scheduler}.</dd>
0 commit comments