Skip to content

Error in documentation of Observable .retry(n) #6402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RobLewis opened this issue Feb 10, 2019 · 5 comments
Closed

Error in documentation of Observable .retry(n) #6402

RobLewis opened this issue Feb 10, 2019 · 5 comments

Comments

@RobLewis
Copy link

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?

@akarnokd
Copy link
Member

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.

@RobLewis
Copy link
Author

RobLewis commented Feb 11, 2019

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" )
                );

@RomanWuattier
Copy link
Contributor

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.

@akarnokd
Copy link
Member

akarnokd commented Apr 9, 2019

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

RomanWuattier added a commit to RomanWuattier/RxJava that referenced this issue Apr 10, 2019
Specify that the `times` function parameter describes "the number of times
to resubscribe if the current Observable fails".

Solves: ReactiveX#6402
RomanWuattier added a commit to RomanWuattier/RxJava that referenced this issue Apr 11, 2019
Specify that the `times` function parameter describes "the number of times
to resubscribe if the current *operator* fails".

Also, this commit updates some unit tests to illustrate the Javadoc wording.

Solves: ReactiveX#6402
RomanWuattier added a commit to RomanWuattier/RxJava that referenced this issue Apr 11, 2019
Specify that the `times` function parameter describes "the number of times
to resubscribe if the current *operator* fails".

Also, this commit updates some unit tests to illustrate the Javadoc wording.

Solves: ReactiveX#6402
RomanWuattier added a commit to RomanWuattier/RxJava that referenced this issue Apr 11, 2019
Specify that the `times` function parameter describes "the number of times
to resubscribe if the current *operator* fails".

Also, this commit updates some unit tests to illustrate the Javadoc wording.

Solves: ReactiveX#6402
akarnokd pushed a commit that referenced this issue Apr 12, 2019
Specify that the `times` function parameter describes "the number of times
to resubscribe if the current *operator* fails".

Also, this commit updates some unit tests to illustrate the Javadoc wording.

Solves: #6402
@akarnokd
Copy link
Member

Closing via #5458.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants