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

Flowable.switchIfEmpty interrupts thread #5370

Closed
jozuasijsling opened this issue May 26, 2017 · 2 comments
Closed

Flowable.switchIfEmpty interrupts thread #5370

jozuasijsling opened this issue May 26, 2017 · 2 comments

Comments

@jozuasijsling
Copy link

jozuasijsling commented May 26, 2017

Is it expected behavior that switchIfEmpty may interrupt its thread?

Problem

Within a switchIfEmpty block, I'm using Completable.blockingAwait(long, TimeUnit) which throws an InterruptedException upon entry because the current thread's interrupt flag is raised.

Analysis

I ran the debugger and stepped through this scenario. SubscriptionArbiter.setSubscription cancels the previous observable before switching to the next. Disposing the observable is done with a call to ScheduledThreadPoolExecutor.ScheduledFutureTask.cancel(true) which then interrupts the thread.

@jozuasijsling jozuasijsling changed the title Observable.switchIfEmpty interrupts thread on 2.x Observable.switchIfEmpty interrupts thread May 26, 2017
@jozuasijsling jozuasijsling changed the title Observable.switchIfEmpty interrupts thread Flowable.switchIfEmpty interrupts thread May 26, 2017
@akarnokd
Copy link
Member

akarnokd commented May 26, 2017

Please try with a newer version as the unnecessary self-interrupt behavior has been already fixed: v2.0.8 via PR #5207.

Also the test case you showed doesn't contain any Scheduler (or an alternate Observable in fact to switch to) thus unless some other test leaves the test thread in an interrupted state, this test should pass.

@jozuasijsling
Copy link
Author

Confirmed! Does not occur with 2.1.0.

In hindsight the test case was rushed and oversimplified so I removed it. Thanks for the help!

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