RxJava icon indicating copy to clipboard operation
RxJava copied to clipboard

Error in documentation of Observable .retry(n)

Open RobLewis opened this issue 7 years ago • 5 comments

There appears to be an error in the 2.x Javadoc for the retry( n ) operator of Observable. n is referred to as "number of retry attempts before failing" but the accompanying marble diagram shows only a single retry when retry(2) is called.

Does n indicate the total number of subscriptions including the first one?

RobLewis avatar Feb 10 '19 20:02 RobLewis

Hello. You could write a small program to find it out and if there is a documentation mistake, you are welcome to post a PR.

akarnokd avatar Feb 10 '19 22:02 akarnokd

My test program (below) shows that the n argument does NOT include the initial attempt to subscribe, thus retry( 10 ) gives a total of 11 subscriptions.

The easiest doc fix would be to change the large retry(2) in the marble diagram to retry(1) but I have no facility for doing that. (The Javadoc for Single doesn't include a marble diagram, but the text description is correct.)

Disposable retryDisp = Observable.error( new SocketTimeoutException() )

                .doOnSubscribe( disp -> System.out.println( "Subscribe count is now " + ++subCount ) )

                .doOnError( err -> System.out.println( "Error count is now " + ++errCount ) )

                .retry( 10 )  // gives a total of 11 subscriptions & 11 errors

                .subscribe(
                        item -> System.out.println( "We never see this" ),
                        err -> System.out.println( "Without this we get a 'missing error handler' crash" )
                );

RobLewis avatar Feb 11 '19 15:02 RobLewis

Does anyone work on this issue? Also, the function parameter times is described as "the number of times to repeat" and could be mixed with the repeat operator. I think that's an opportunity to improve the Javadoc of public final Observable<T> retry(long times, Predicate<? super Throwable> predicate) at the same time.

RomanWuattier avatar Apr 09 '19 21:04 RomanWuattier

@RomanWuattier Nobody seems to work on this so you are welcome if you want.

akarnokd avatar Apr 09 '19 21:04 akarnokd

Closing via #5458.

akarnokd avatar Apr 12 '19 12:04 akarnokd