Skip to content
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

Is delaySubscription() interrupts the thread immediately as expected? #5203

Closed
hkurokawa opened this issue Mar 20, 2017 · 4 comments
Closed

Comments

@hkurokawa
Copy link
Contributor

I ran the below test code with RxJava 2.0.7 and got a failure which succeeded with RxJava 1.x.

    final TestObserver<Boolean> observer = TestObserver.create();
    Observable.<Boolean>create(emitter -> {
      emitter.onNext(Thread.interrupted());
      emitter.onComplete();
    })
        .delaySubscription(100, TimeUnit.MICROSECONDS)
        .subscribe(observer);
    observer.awaitTerminalEvent();
    observer.assertValue(false);
  }

If I put subscribeOn() before delaySubscription(), it does not fail.

I am not sure if it is as expected so want to know if it is the expected behaviour.

Here is some background of my issue: I am using RxJava 2.0.7 with Retrofit 2.2.0 and it seems Retrofit (precisely speaking, Okio, which is being used in OkHttp) throws an error when the thread is interrupted while it tries to read the HTTP response. I am trying to delay the HTTP call to achieve something like debounce() with delaySubscription() operator and encountered this issue. I have a workaround so just want to know if it is the expected behaviour.

Thank you for your support in advance.

@akarnokd
Copy link
Member

This is an unexpected side-effect of cancelling the delay timer inside the delaySubscription operator. I'll post a fix for it shortly.

@akarnokd
Copy link
Member

See #5207.

@hkurokawa
Copy link
Contributor Author

Thank you for your prompt work on this. Waiting for the next release including this fix.

@akarnokd
Copy link
Member

Closing via #5207.

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

2 participants