@@ -11770,19 +11770,19 @@ public final Flowable<T> retryUntil(final BooleanSupplier stop) {
11770
11770
* resubscribe to the source Publisher.
11771
11771
* <p>
11772
11772
* <img width="640" height="430" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/retryWhen.f.png" alt="">
11773
- *
11773
+ * <p>
11774
11774
* Example:
11775
11775
*
11776
11776
* This retries 3 times, each time incrementing the number of seconds it waits.
11777
11777
*
11778
11778
* <pre><code>
11779
- * Publisher .create((Subscriber <? super String> s) -> {
11779
+ * Flowable .create((FlowableEmitter <? super String> s) -> {
11780
11780
* System.out.println("subscribing");
11781
11781
* s.onError(new RuntimeException("always fails"));
11782
- * }).retryWhen(attempts -> {
11782
+ * }, BackpressureStrategy.BUFFER ).retryWhen(attempts -> {
11783
11783
* return attempts.zipWith(Flowable.range(1, 3), (n, i) -> i).flatMap(i -> {
11784
11784
* System.out.println("delay retry by " + i + " second(s)");
11785
- * return Publisher .timer(i, TimeUnit.SECONDS);
11785
+ * return Flowable .timer(i, TimeUnit.SECONDS);
11786
11786
* });
11787
11787
* }).blockingForEach(System.out::println);
11788
11788
* </code></pre>
@@ -11798,9 +11798,35 @@ public final Flowable<T> retryUntil(final BooleanSupplier stop) {
11798
11798
* delay retry by 3 second(s)
11799
11799
* subscribing
11800
11800
* } </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>
11801
11826
* <dl>
11802
11827
* <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.
11804
11830
* If this expectation is violated, the operator <em>may</em> throw an {@code IllegalStateException}.</dd>
11805
11831
* <dt><b>Scheduler:</b></dt>
11806
11832
* <dd>{@code retryWhen} does not operate by default on a particular {@link Scheduler}.</dd>
0 commit comments