Skip to content

retryWhen method signature for with Completable and Single #5135

Closed
@jeremy303

Description

@jeremy303

When I attempt to use retryWhen to delay a retry with Completable or Single I receive an incompatible types error, as demonstrated in the following code:

        Completable.error(new RuntimeException())
                .retryWhen(new Function<Flowable<Throwable>, Publisher<Object>>() {
                    @Override
                    public Publisher<Object> apply(@io.reactivex.annotations.NonNull Flowable<Throwable> source) throws Exception {
                        return source.delay(5, TimeUnit.SECONDS); // <- Incompatible type error
                    }
                });
        
        Single.error(new RuntimeException())
                .retryWhen(new Function<Flowable<Throwable>, Publisher<Object>>() {
                    @Override
                    public Publisher<Object> apply(@io.reactivex.annotations.NonNull Flowable<Throwable> source) throws Exception {
                        return source.delay(5, TimeUnit.SECONDS); // <- Incompatible type error
                    }
                });

However, there are no issues with Observable or Flowable:

        Observable.error(new RuntimeException())
                .retryWhen(new Function<Observable<Throwable>, ObservableSource<?>>() {
                    @Override
                    public ObservableSource<?> apply(@io.reactivex.annotations.NonNull Observable<Throwable> source) throws Exception {
                        return source.delay(5, TimeUnit.SECONDS);
                    }
                });
        Flowable.error(new RuntimeException())
                .retryWhen(new Function<Flowable<Throwable>, Publisher<?>>() {
                    @Override
                    public Publisher<?> apply(@io.reactivex.annotations.NonNull Flowable<Throwable> source) throws Exception {
                        return source.delay(5, TimeUnit.SECONDS);
                    }
                });

Looks like there is an issue with the return types for apply?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions