Error in documentation of Observable .retry(n)
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?
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.
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" )
);
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 Nobody seems to work on this so you are welcome if you want.
Closing via #5458.